/* * memory.h: interface for the memory allocation debugger. * * Daniel.Veillard@w3.org */ #ifndef _DEBUG_MEMORY_ALLOC_ #define _DEBUG_MEMORY_ALLOC_ /* #define NO_DEBUG_MEMORY */ #ifdef __INSIGHT__ #define NO_DEBUG_MEMORY #endif #ifdef NO_DEBUG_MEMORY #include #define debugFree(x) free((x)) #define debugMalloc(x) malloc(x) #define debugRealloc(p, x) realloc((p), (x)) #define debugStrdup(x) strdup((x)) #define debugInitMemory() #define debugMemUsed() #define debugInitMemory() #define debugMemoryDump() #define debugMemDisplay(x) #else /* ! NO_DEBUG_MEMORY */ #include /* #define DEBUG_MEMORY */ /* */ #define DEBUG_MEMORY_LOCATION #ifdef DEBUG #ifndef DEBUG_MEMORY #define DEBUG_MEMORY #endif #endif #define MEM_LIST /* keep a list of all the allocated memory blocks */ /* initialization functions */ extern int debugInitMemory(void); extern void * debugMalloc(int size); extern void * debugRealloc(void *ptr,int size); extern int debugFree(void *ptr); extern char * debugStrdup(const char *str); extern int debugMemUsed(void); extern void debugMemDisplay(FILE *fp); extern int debugInitMemory(void); #ifdef DEBUG_MEMORY_LOCATION #define debugMalloc(x) debugMallocLoc((x), __FILE__, __LINE__) #define debugRealloc(p, x) debugReallocLoc((p), (x), __FILE__, __LINE__) #define debugStrdup(x) debugStrdupLoc((x), __FILE__, __LINE__) extern void * debugMallocLoc(int size, const char *file, int line); extern void * debugReallocLoc(void *ptr,int size, const char *file, int line); extern char * debugStrdupLoc(const char *str, const char *file, int line); #endif /* DEBUG_MEMORY_LOCATION */ #endif /* ! NO_DEBUG_MEMORY */ #endif /* _DEBUG_MEMORY_ALLOC_ */