File:  [Public] / rpm2html / memory.h
Revision 1.8: download - view: text, annotated - select for diffs
Wed Sep 6 09:44:24 2000 UTC (24 years ago) by veillard
Branches: MAIN
CVS tags: RPM2HTML_1_5, HEAD
This shoukd fix the "rufus bug" reported on gnorpm, Daniel

/*
 * memory.h: interface for the memory allocation debugger.
 *
 * Daniel.Veillard@w3.org
 */


#ifndef _RPM2HTML_DEBUG_MEMORY_ALLOC_
#define _RPM2HTML_DEBUG_MEMORY_ALLOC_

#define NO_DEBUG_MEMORY

#ifdef __INSIGHT__
#define NO_DEBUG_MEMORY
#endif

#ifdef NO_DEBUG_MEMORY
#include <malloc.h>

#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 <stdio.h>

/* #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  /* _RPM2HTML_DEBUG_MEMORY_ALLOC_ */


Webmaster