00001 #ifndef __MEM_H
00002 #define __MEM_H
00003
00004 #ifdef __HAVE_LEAK_DETECTION
00005
00006 #define NAMEOF(v) #v
00007 #define xmalloc(x) MM_malloc(x, __FILE__, __LINE__)
00008 #define xfree(x) MM_free(x, __FILE__, __LINE__, NAMEOF(x))
00009 #define xstrdup(x) MM_strdup(x, __FILE__, __LINE__)
00010 #define xrealloc(x, y) MM_realloc(x, y, __FILE__, __LINE__)
00011
00012 TAILQ_HEAD(MM_chunks, MM_mem_chunk);
00013
00014 struct MM_mem_chunk {
00015 void *address;
00016 const char *filename;
00017 u_int32_t line;
00018 size_t size;
00019
00020 TAILQ_ENTRY(MM_mem_chunk) next;
00021 };
00022
00023 void *MM_malloc(size_t, char *, int);
00024 void *MM_realloc(void *, size_t, char *, int);
00025 void MM_free(void *, char *, int, char *);
00026 char *MM_strdup(const char *, char *, int);
00027 void MM_leakd_init(void);
00028 void MM_leakd_printallocated(void);
00029 void MM_leakd_flush(void);
00030
00031 #endif
00032 #endif