Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

xmlmemory.h

Go to the documentation of this file.
00001 /*
00002  * xmlmemory.h: interface for the memory allocation debug.
00003  *
00004  * daniel@veillard.com
00005  */
00006 
00007 
00008 #ifndef __DEBUG_MEMORY_ALLOC__
00009 #define __DEBUG_MEMORY_ALLOC__
00010 
00011 #include <stdio.h>
00012 #include <libxml/xmlversion.h>
00013 
00022 /* #define DEBUG_MEMORY_FREED */
00023 /* #define DEBUG_MEMORY_LOCATION */
00024 
00025 #ifdef DEBUG
00026 #ifndef DEBUG_MEMORY
00027 #define DEBUG_MEMORY
00028 #endif
00029 #endif
00030 
00037 #ifdef DEBUG_MEMORY_LOCATION
00038 #endif
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 /*
00045  * The XML memory wrapper support 4 basic overloadable functions.
00046  */
00053 typedef void (*xmlFreeFunc)(void *mem);
00062 typedef void *(*xmlMallocFunc)(size_t size);
00063 
00073 typedef void *(*xmlReallocFunc)(void *mem, size_t size);
00074 
00083 typedef char *(*xmlStrdupFunc)(const char *str);
00084 
00085 /*
00086  * The 4 interfaces used for all memory handling within libxml.
00087 LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree;
00088 LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc;
00089 LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMallocAtomic;
00090 LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc;
00091 LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup;
00092  */
00093 
00094 /*
00095  * The way to overload the existing functions.
00096  * The xmlGc function have an extra entry for atomic block
00097  * allocations useful for garbage collected memory allocators
00098  */
00099 XMLPUBFUN int XMLCALL
00100         xmlMemSetup     (xmlFreeFunc freeFunc,
00101                          xmlMallocFunc mallocFunc,
00102                          xmlReallocFunc reallocFunc,
00103                          xmlStrdupFunc strdupFunc);
00104 XMLPUBFUN int XMLCALL     
00105         xmlMemGet       (xmlFreeFunc *freeFunc,
00106                          xmlMallocFunc *mallocFunc,
00107                          xmlReallocFunc *reallocFunc,
00108                          xmlStrdupFunc *strdupFunc);
00109 XMLPUBFUN int XMLCALL     
00110         xmlGcMemSetup   (xmlFreeFunc freeFunc,
00111                          xmlMallocFunc mallocFunc,
00112                          xmlMallocFunc mallocAtomicFunc,
00113                          xmlReallocFunc reallocFunc,
00114                          xmlStrdupFunc strdupFunc);
00115 XMLPUBFUN int XMLCALL     
00116         xmlGcMemGet     (xmlFreeFunc *freeFunc,
00117                          xmlMallocFunc *mallocFunc,
00118                          xmlMallocFunc *mallocAtomicFunc,
00119                          xmlReallocFunc *reallocFunc,
00120                          xmlStrdupFunc *strdupFunc);
00121 
00122 /*
00123  * Initialization of the memory layer.
00124  */
00125 XMLPUBFUN int XMLCALL   
00126         xmlInitMemory   (void);
00127 
00128 /*
00129  * These are specific to the XML debug memory wrapper.
00130  */
00131 XMLPUBFUN int XMLCALL   
00132         xmlMemUsed      (void);
00133 XMLPUBFUN void XMLCALL  
00134         xmlMemDisplay   (FILE *fp);
00135 XMLPUBFUN void XMLCALL  
00136         xmlMemShow      (FILE *fp, int nr);
00137 XMLPUBFUN void XMLCALL  
00138         xmlMemoryDump   (void);
00139 XMLPUBFUN void * XMLCALL        
00140         xmlMemMalloc    (size_t size);
00141 XMLPUBFUN void * XMLCALL        
00142         xmlMemRealloc   (void *ptr,size_t size);
00143 XMLPUBFUN void XMLCALL  
00144         xmlMemFree      (void *ptr);
00145 XMLPUBFUN char * XMLCALL        
00146         xmlMemoryStrdup (const char *str);
00147 XMLPUBFUN void * XMLCALL  
00148         xmlMallocLoc    (size_t size, const char *file, int line);
00149 XMLPUBFUN void * XMLCALL        
00150         xmlReallocLoc   (void *ptr, size_t size, const char *file, int line);
00151 XMLPUBFUN void * XMLCALL        
00152         xmlMallocAtomicLoc (size_t size, const char *file, int line);
00153 XMLPUBFUN char * XMLCALL        
00154         xmlMemStrdupLoc (const char *str, const char *file, int line);
00155 
00156 
00157 #ifdef DEBUG_MEMORY_LOCATION
00158 
00166 #define xmlMalloc(size) xmlMallocLoc((size), __FILE__, __LINE__)
00167 
00176 #define xmlMallocAtomic(size) xmlMallocAtomicLoc((size), __FILE__, __LINE__)
00177 
00186 #define xmlRealloc(ptr, size) xmlReallocLoc((ptr), (size), __FILE__, __LINE__)
00187 
00195 #define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__)
00196 
00197 #endif /* DEBUG_MEMORY_LOCATION */
00198 
00199 #ifdef __cplusplus
00200 }
00201 #endif /* __cplusplus */
00202 
00203 #ifndef __XML_GLOBALS_H
00204 #ifndef __XML_THREADS_H__
00205 #include <libxml/threads.h>
00206 #include <libxml/globals.h>
00207 #endif
00208 #endif
00209 
00210 #endif  /* __DEBUG_MEMORY_ALLOC__ */
00211 
00212 

Generated on Wed Mar 16 00:10:27 2005 for Dibbler - a portable DHCPv6 by  doxygen 1.3.9.1