diff options
Diffstat (limited to 'src/lib/memutils.cpp')
-rw-r--r-- | src/lib/memutils.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/memutils.cpp b/src/lib/memutils.cpp new file mode 100644 index 0000000..e12b208 --- /dev/null +++ b/src/lib/memutils.cpp | |||
@@ -0,0 +1,27 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <iostream> | ||
3 | #include "memutils.h" | ||
4 | #define MEMDEBUG 0 | ||
5 | void* memutils::mymalloc(const char* wherefrom,__uint32 elcount,__uint32 elsize) | ||
6 | { | ||
7 | void* q=calloc(elcount,elsize); | ||
8 | #if (MEMDEBUG==1) | ||
9 | cout << "ALLOC: " << wherefrom | ||
10 | <<" allocated " | ||
11 | << elcount<<" bytes at " << q << endl; | ||
12 | #else | ||
13 | wherefrom=NULL; | ||
14 | #endif | ||
15 | return q; | ||
16 | } | ||
17 | |||
18 | void memutils::myfree(const char* wherefrom,void* freewhat) | ||
19 | { | ||
20 | #if (MEMDEBUG==1) | ||
21 | cout << "FREE: "<< wherefrom <<" free bytes at " << freewhat << endl; | ||
22 | #else | ||
23 | wherefrom=NULL; | ||
24 | #endif | ||
25 | free(freewhat); | ||
26 | } | ||
27 | |||