00001 #ifndef DBG_MEM_H 00002 #define DBG_MEM_H 00003 00004 #include <stdlib.h> 00005 00006 #ifdef __cplusplus 00007 00008 #ifdef DEBUG_MEMORY 00009 00010 void *operator new (size_t); 00011 void operator delete (void *); 00012 00013 #endif 00014 00015 extern "C" 00016 { 00017 #endif 00018 00019 void *debug_malloc (const char *file, int line, size_t); 00020 void *debug_calloc (const char *file, int line, size_t, size_t); 00021 void *debug_realloc (const char *file, int line, void *, size_t); 00022 void debug_free (void *); 00023 00024 void disable_debug_memory (); 00025 void enable_debug_memory (); 00026 void clear_dbg_mem_list (); 00027 void print_dbg_mem_list (); 00028 00029 extern int log_debug_mem_list; 00030 extern int print_debug_mem_calls; 00031 extern int next_log_debug_id; 00032 00033 00034 #ifdef __cplusplus 00035 }; 00036 #endif 00037 00038 #ifdef DEBUG_MEMORY 00039 00040 #define DEBUG_MALLOC(X) debug_malloc(__FILE__, __LINE__, X) 00041 #define DEBUG_CALLOC(X,Y) debug_calloc(__FILE__, __LINE__, X, Y) 00042 #define DEBUG_REALLOC(X,Y) debug_realloc(__FILE__, __LINE__, X, Y) 00043 #define DEBUG_FREE debug_free 00044 00045 #else 00046 00047 #ifndef DEBUG_MALLOC 00048 #define DEBUG_MALLOC malloc 00049 #endif 00050 #define DEBUG_CALLOC calloc 00051 #define DEBUG_REALLOC realloc 00052 #ifndef DEBUG_FREE 00053 #define DEBUG_FREE free 00054 #endif 00055 00056 #endif 00057 00058 #endif