blob: 64477a1ce0a86e1ea4e2c66d20887f72f7cc2a4c [file] [log] [blame]
Daniel Veillard6454aec1999-09-02 22:04:43 +00001/*
Daniel Veillarddbfd6411999-12-28 16:35:14 +00002 * xmlmemory.h: interface for the memory allocation debug.
Daniel Veillard6454aec1999-09-02 22:04:43 +00003 *
4 * Daniel.Veillard@w3.org
5 */
6
7
8#ifndef _DEBUG_MEMORY_ALLOC_
9#define _DEBUG_MEMORY_ALLOC_
10
Daniel Veillard962195f1999-10-28 15:51:53 +000011#define NO_DEBUG_MEMORY
Daniel Veillard6454aec1999-09-02 22:04:43 +000012
13#ifdef NO_DEBUG_MEMORY
14#ifdef HAVE_MALLOC_H
15#include <malloc.h>
16#endif
17
18#define xmlFree(x) free((x))
19#define xmlMalloc(x) malloc(x)
20#define xmlRealloc(p, x) realloc((p), (x))
21#define xmlMemStrdup(x) strdup((x))
22#define xmlInitMemory()
23#define xmlMemUsed()
24#define xmlInitMemory()
25#define xmlMemoryDump()
26#define xmlMemDisplay(x)
Daniel Veillarddbfd6411999-12-28 16:35:14 +000027#define xmlMemShow(x, d)
Daniel Veillard6454aec1999-09-02 22:04:43 +000028
29#else /* ! NO_DEBUG_MEMORY */
30#include <stdio.h>
31
32/* #define DEBUG_MEMORY */ /* */
33
34#define DEBUG_MEMORY_LOCATION
35
36#ifdef DEBUG
37#ifndef DEBUG_MEMORY
38#define DEBUG_MEMORY
39#endif
40#endif
41
42#define MEM_LIST /* keep a list of all the allocated memory blocks */
43
Daniel Veillard5cb5ab81999-12-21 15:35:29 +000044#ifdef __cplusplus
45extern "C" {
46#endif
Daniel Veillard6454aec1999-09-02 22:04:43 +000047int xmlInitMemory (void);
48void * xmlMalloc (int size);
49void * xmlRealloc (void *ptr,
50 int size);
51void xmlFree (void *ptr);
52char * xmlMemStrdup (const char *str);
53int xmlMemUsed (void);
54void xmlMemDisplay (FILE *fp);
Daniel Veillarddbfd6411999-12-28 16:35:14 +000055void xmlMemShow (FILE *fp, int nr);
Daniel Veillard6454aec1999-09-02 22:04:43 +000056void xmlMemoryDump (void);
57int xmlInitMemory (void);
58
59#ifdef DEBUG_MEMORY_LOCATION
60#define xmlMalloc(x) xmlMallocLoc((x), __FILE__, __LINE__)
61#define xmlRealloc(p, x) xmlReallocLoc((p), (x), __FILE__, __LINE__)
62#define xmlMemStrdup(x) xmlMemStrdupLoc((x), __FILE__, __LINE__)
63
64extern void * xmlMallocLoc(int size, const char *file, int line);
65extern void * xmlReallocLoc(void *ptr,int size, const char *file, int line);
66extern char * xmlMemStrdupLoc(const char *str, const char *file, int line);
Daniel Veillard5cb5ab81999-12-21 15:35:29 +000067#ifdef __cplusplus
68}
69#endif
Daniel Veillard6454aec1999-09-02 22:04:43 +000070#endif /* DEBUG_MEMORY_LOCATION */
71#endif /* ! NO_DEBUG_MEMORY */
72
73#endif /* _DEBUG_MEMORY_ALLOC_ */
74