gonzui


Format: Advanced Search

tkernel_2/lib/libtk/src/kmalloc.cbare sourcepermlink (0.01 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T-Kernel 2.0 Software Package
    4:  *
    5:  *    Copyright 2011 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17.
   10:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
   11:  *
   12:  *----------------------------------------------------------------------
   13:  */
   14: 
   15: /*
   16:  *      @(#)kmalloc.c (libtk)
   17:  *
   18:  *      Resident system memory allocation
   19:  */
   20: 
   21: #include "libtk.h"
   22: 
   23: #ifndef KMALLOCTEST
   24: 
   25: EXPORT void* Kmalloc( size_t size )
   26: {
   27:         void   *p;
   28: 
   29:         MEMLOCK( return NULL )
   30:         p = _mem_malloc(size, &_Kmacb);
   31:         MEMUNLOCK()
   32: 
   33:         return p;
   34: }
   35: 
   36: EXPORT void* Kcalloc( size_t nmemb, size_t size )
   37: {
   38:         void   *p;
   39: 
   40:         MEMLOCK( return NULL )
   41:         p = _mem_calloc(nmemb, size, &_Kmacb);
   42:         MEMUNLOCK()
   43: 
   44:         return p;
   45: }
   46: 
   47: EXPORT void* Krealloc( void *ptr, size_t size )
   48: {
   49:         void   *p;
   50: 
   51:         MEMLOCK( return NULL )
   52:         p = _mem_realloc(ptr, size, &_Kmacb);
   53:         MEMUNLOCK()
   54: 
   55:         return p;
   56: }
   57: 
   58: EXPORT void Kfree( void *ptr )
   59: {
   60:         MEMLOCK( return )
   61:         _mem_free(ptr, &_Kmacb);
   62:         MEMUNLOCK()
   63: }
   64: 
   65: #else /* KMALLOCTEST */
   66: 
   67: EXPORT void Kmalloctest( int mode )
   68: {
   69:         MEMLOCK( return )
   70:         _mem_malloctest(mode, &_Kmacb);
   71:         MEMUNLOCK()
   72: }
   73: 
   74: EXPORT BOOL Kmalloccheck( void *ptr )
   75: {
   76:         BOOL   v;
   77: 
   78:         MEMLOCK( return FALSE )
   79:         v = _mem_malloccheck(ptr, &_Kmacb);
   80:         MEMUNLOCK()
   81: 
   82:         return v;
   83: }
   84: 
   85: #endif /* KMALLOCTEST */