Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/glutess/memalloc is written in an unsupported language. File is not indexed.

0001 // see license file for original license.
0002 
0003 #ifndef tools_glutess_memalloc
0004 #define tools_glutess_memalloc
0005 
0006 ////////////////////////////////////////////////////////
0007 /// inlined C code : ///////////////////////////////////
0008 ////////////////////////////////////////////////////////
0009 
0010 #ifdef TOOLS_MEM
0011 #include "../mem"
0012 #include <cstdlib>
0013 namespace tools {
0014 inline void* mem_alloc(size_t a_size){
0015   mem::increment(tools::s_malloc().c_str());
0016   return ::malloc(a_size);
0017 }
0018 inline void* mem_realloc(void* a_ptr,size_t a_size){
0019   if(a_ptr==NULL) mem::increment(tools::s_malloc().c_str());
0020   return ::realloc(a_ptr,a_size);
0021 }
0022 inline void mem_free(void* a_ptr){
0023   if(a_ptr!=NULL) mem::decrement(tools::s_malloc().c_str());
0024   ::free(a_ptr);
0025 }
0026 inline int mem_init( size_t /*maxFast*/) {return 1;}
0027 
0028 }
0029 #else
0030 #include <cstdlib>
0031 #include <cstring>
0032 namespace tools {
0033 inline void* mem_alloc(size_t a_size) {return ::memset( ::malloc( a_size ), 0xa5, a_size);}
0034 inline void* mem_realloc(void* a_ptr,size_t a_size){return ::realloc(a_ptr,a_size);}
0035 inline void mem_free(void* a_ptr){::free(a_ptr);}
0036 inline int mem_init( size_t /*maxFast*/) {return 1;}
0037 }
0038 #endif
0039 
0040 #define memAlloc        tools::mem_alloc
0041 #define memRealloc      tools::mem_realloc
0042 #define memFree         tools::mem_free
0043 #define memInit         tools::mem_init
0044 
0045 #endif