gonzui


Format: Advanced Search

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