Main Page   File List   Globals  

leakbug.h

Go to the documentation of this file.
00001 
00023 #ifndef _LEAKBUG_H_
00024 #define _LEAKBUG_H_
00025 
00026 /*
00027  * We should include these now, so that we can #undef the functions in
00028  * this file.
00029  */
00030 #include <string.h>
00031 #include <stdlib.h>
00032 
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036 
00049 void *lbMalloc(size_t size, const char *filename, int line, int debug_level);
00050 
00064 void *lbCalloc(size_t nmemb, size_t size, const char *filename, int line,
00065                int debug_level);
00066 
00080 void *lbRealloc(void *data, size_t size, const char *filename, int line,
00081                 int debug_level);
00082 
00093 void lbFree(void *ptr, const char *filename, int line, int debug_level);
00094 
00126 void *lbRegister(void *ptr, unsigned int dataSize, const char *filename,
00127                  int line, int debug_level);
00128 
00162 void **lbRegisterArray(void **ptr, unsigned int dataSize,
00163                        unsigned int numElements, const char *filename,
00164                        int line, int debug_level);
00165 
00172 void lbFreeLeaks(void);
00173 
00177 void lbDumpLeaks(void);
00178 
00183 #define LEAKBUG_SILENT   0  
00184 #define LEAKBUG_WARNINGS 1  
00185 #define LEAKBUG_ERRORS   2  
00187 
00188 #ifndef _DOXYGEN_
00189 # ifndef LEAKBUG_NO_DEBUG
00190 #  ifndef LEAKBUG_DEBUG_LEVEL
00191 #   define LEAKBUG_DEBUG_LEVEL (LEAKBUG_WARNINGS | LEAKBUG_ERRORS)
00192 #  endif
00193 
00194 #  undef malloc
00195 #  undef calloc
00196 #  undef realloc
00197 #  undef free
00198 #  undef strdup
00199 
00200 #  define malloc(x) lbMalloc((x),  __FILE__, __LINE__, LEAKBUG_DEBUG_LEVEL)
00201 #  define calloc(n, x) \
00202     lbCalloc((n), (x), __FILE__, __LINE__, LEAKBUG_DEBUG_LEVEL)
00203 #  define realloc(d, x) \
00204     lbRealloc((d), (x), __FILE__, __LINE__, LEAKBUG_DEBUG_LEVEL)
00205 #  define free(x)   lbFree((x),    __FILE__, __LINE__, LEAKBUG_DEBUG_LEVEL)
00206 
00207 #  define strdup(x) lbRegister(strdup(x), (strlen(x) + 1) * sizeof(char), \
00208                                __FILE__, __LINE__, LEAKBUG_DEBUG_LEVEL)
00209 # endif /* !LEAKBUG_NO_DEBUG */
00210 #endif
00211 
00212 #ifdef __cplusplus
00213 }
00214 #endif
00215 
00216 #endif /* _LEAKBUG_H_ */

Generated on Mon Jul 1 21:01:00 2002 for leakbug by doxygen1.2.15-20020430