g4tools  5.4.0
memalloc
Go to the documentation of this file.
1 // see license file for original license.
2 
3 #ifndef tools_glutess_memalloc
4 #define tools_glutess_memalloc
5 
9 
10 #ifdef TOOLS_MEM
11 #include "../mem"
12 #include <cstdlib>
13 namespace tools {
14 inline void* mem_alloc(size_t a_size){
15  mem::increment(tools::s_malloc().c_str());
16  return ::malloc(a_size);
17 }
18 inline void* mem_realloc(void* a_ptr,size_t a_size){
19  if(a_ptr==NULL) mem::increment(tools::s_malloc().c_str());
20  return ::realloc(a_ptr,a_size);
21 }
22 inline void mem_free(void* a_ptr){
23  if(a_ptr!=NULL) mem::decrement(tools::s_malloc().c_str());
24  ::free(a_ptr);
25 }
26 inline int mem_init( size_t /*maxFast*/) {return 1;}
27 
28 }
29 #else
30 #include <cstdlib>
31 #include <cstring>
32 namespace tools {
33 inline void* mem_alloc(size_t a_size) {return ::memset( ::malloc( a_size ), 0xa5, a_size);}
34 inline void* mem_realloc(void* a_ptr,size_t a_size){return ::realloc(a_ptr,a_size);}
35 inline void mem_free(void* a_ptr){::free(a_ptr);}
36 inline int mem_init( size_t /*maxFast*/) {return 1;}
37 }
38 #endif
39 
40 #define memAlloc tools::mem_alloc
41 #define memRealloc tools::mem_realloc
42 #define memFree tools::mem_free
43 #define memInit tools::mem_init
44 
45 #endif
tools::mem_alloc
void * mem_alloc(size_t a_size)
Definition: memalloc:33
tools::realloc
bool realloc(T *&a_pointer, size_t a_new_size, size_t a_old_size, bool a_init=false)
Definition: realloc:9
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::mem_init
int mem_init(size_t)
Definition: memalloc:36
tools::mem_free
void mem_free(void *a_ptr)
Definition: memalloc:35
tools::mem_realloc
void * mem_realloc(void *a_ptr, size_t a_size)
Definition: memalloc:34