gonzui


Format: Advanced Search

tkernel_2/lib/libtk/src/smalloc.cbare sourcepermlink (0.00 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:  *      @(#)smalloc.c (libtk)
   17:  *
   18:  *      Non-resident shared memory allocation
   19:  */
   20: 
   21: #include "libtk.h"
   22: 
   23: #ifndef SMALLOCTEST
   24: 
   25: EXPORT void* Smalloc( size_t size )
   26: {
   27:         void   *p;
   28: 
   29:         MEMLOCK( return NULL )
   30:         p = _mem_malloc(size, &_Smacb);
   31:         MEMUNLOCK()
   32: 
   33:         return p;
   34: }
   35: 
   36: EXPORT void* Scalloc( size_t nmemb, size_t size )
   37: {
   38:         void   *p;
   39: 
   40:         MEMLOCK( return NULL )
   41:         p = _mem_calloc(nmemb, size, &_Smacb);
   42:         MEMUNLOCK()
   43: 
   44:         return p;
   45: }
   46: 
   47: EXPORT void* Srealloc( void *ptr, size_t size )
   48: {
   49:         void   *p;
   50: 
   51:         MEMLOCK( return NULL )
   52:         p = _mem_realloc(ptr, size, &_Smacb);
   53:         MEMUNLOCK()
   54: 
   55:         return p;
   56: }
   57: 
   58: EXPORT void Sfree( void *ptr )
   59: {
   60:         MEMLOCK( return )
   61:         _mem_free(ptr, &_Smacb);
   62:         MEMUNLOCK()
   63: }
   64: 
   65: #else /* SMALLOCTEST */
   66: 
   67: EXPORT void Smalloctest( int mode )
   68: {
   69:         MEMLOCK( return )
   70:         _mem_malloctest(mode, &_Smacb);
   71:         MEMUNLOCK()
   72: }
   73: 
   74: EXPORT BOOL Smalloccheck( void *ptr )
   75: {
   76:         BOOL   v;
   77: 
   78:         MEMLOCK( return FALSE )
   79:         v = _mem_malloccheck(ptr, &_Smacb);
   80:         MEMUNLOCK()
   81: 
   82:         return v;
   83: }
   84: 
   85: #endif /* SMALLOCTEST */