2 * xmlmemory.c: libxml memory allocator wrapper.
12 #ifdef HAVE_SYS_TYPES_H
13 #include <sys/types.h>
32 /* #define DEBUG_MEMORY */
37 * keep track of all allocated blocks for error reporting
38 * Always build the memory list !
40 #ifdef DEBUG_MEMORY_LOCATION
42 #define MEM_LIST /* keep a list of all the allocated memory blocks */
46 #include <libxml/globals.h> /* must come before xmlmemory.h */
47 #include <libxml/xmlmemory.h>
48 #include <libxml/xmlerror.h>
49 #include <libxml/threads.h>
51 static int xmlMemInitialized = 0;
52 static unsigned long debugMemSize = 0;
53 static unsigned long debugMemBlocks = 0;
54 static unsigned long debugMaxMemSize = 0;
55 static xmlMutexPtr xmlMemMutex = NULL;
57 void xmlMallocBreakpoint(void);
59 /************************************************************************
61 * Macros, variables and associated types *
63 ************************************************************************/
65 #if !defined(LIBXML_THREAD_ENABLED) && !defined(LIBXML_THREAD_ALLOC_ENABLED)
78 * Each of the blocks allocated begin with a header containing informations
84 #define REALLOC_TYPE 2
86 #define MALLOC_ATOMIC_TYPE 4
87 #define REALLOC_ATOMIC_TYPE 5
89 typedef struct memnod {
92 unsigned long mh_number;
95 struct memnod *mh_next;
96 struct memnod *mh_prev;
104 #define ALIGN_SIZE 16
106 #define ALIGN_SIZE sizeof(double)
108 #define HDR_SIZE sizeof(MEMHDR)
109 #define RESERVE_SIZE (((HDR_SIZE + (ALIGN_SIZE-1)) \
110 / ALIGN_SIZE ) * ALIGN_SIZE)
113 #define CLIENT_2_HDR(a) ((MEMHDR *) (((char *) (a)) - RESERVE_SIZE))
114 #define HDR_2_CLIENT(a) ((void *) (((char *) (a)) + RESERVE_SIZE))
117 static unsigned int block=0;
118 static unsigned int xmlMemStopAtBlock = 0;
119 static void *xmlMemTraceBlockAt = NULL;
121 static MEMHDR *memlist = NULL;
124 static void debugmem_tag_error(void *addr);
126 static void debugmem_list_add(MEMHDR *);
127 static void debugmem_list_delete(MEMHDR *);
129 #define Mem_Tag_Err(a) debugmem_tag_error(a);
136 * xmlMallocBreakpoint:
138 * Breakpoint to use in conjunction with xmlMemStopAtBlock. When the block
139 * number reaches the specified value this function is called. One need to add a breakpoint
140 * to it to get the context in which the given block is allocated.
144 xmlMallocBreakpoint(void) {
145 xmlGenericError(xmlGenericErrorContext,
146 "xmlMallocBreakpoint reached on block %d\n", xmlMemStopAtBlock);
151 * @size: an int specifying the size in byte to allocate.
152 * @file: the file name or NULL
153 * @line: the line number
155 * a malloc() equivalent, with logging of the allocation info.
157 * Returns a pointer to the allocated area or NULL in case of lack of memory.
161 xmlMallocLoc(size_t size, const char * file, int line)
166 if (!xmlMemInitialized) xmlInitMemory();
168 xmlGenericError(xmlGenericErrorContext,
169 "Malloc(%d)\n",size);
174 p = (MEMHDR *) malloc(RESERVE_SIZE+size);
177 xmlGenericError(xmlGenericErrorContext,
178 "xmlMallocLoc : Out of free space\n");
184 p->mh_type = MALLOC_TYPE;
187 xmlMutexLock(xmlMemMutex);
188 p->mh_number = ++block;
189 debugMemSize += size;
191 if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
193 debugmem_list_add(p);
195 xmlMutexUnlock(xmlMemMutex);
198 xmlGenericError(xmlGenericErrorContext,
199 "Malloc(%d) Ok\n",size);
202 if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
204 ret = HDR_2_CLIENT(p);
206 if (xmlMemTraceBlockAt == ret) {
207 xmlGenericError(xmlGenericErrorContext,
208 "%p : Malloc(%lu) Ok\n", xmlMemTraceBlockAt,
209 (long unsigned)size);
210 xmlMallocBreakpoint();
219 * xmlMallocAtomicLoc:
220 * @size: an int specifying the size in byte to allocate.
221 * @file: the file name or NULL
222 * @line: the line number
224 * a malloc() equivalent, with logging of the allocation info.
226 * Returns a pointer to the allocated area or NULL in case of lack of memory.
230 xmlMallocAtomicLoc(size_t size, const char * file, int line)
235 if (!xmlMemInitialized) xmlInitMemory();
237 xmlGenericError(xmlGenericErrorContext,
238 "Malloc(%d)\n",size);
243 p = (MEMHDR *) malloc(RESERVE_SIZE+size);
246 xmlGenericError(xmlGenericErrorContext,
247 "xmlMallocLoc : Out of free space\n");
253 p->mh_type = MALLOC_ATOMIC_TYPE;
256 xmlMutexLock(xmlMemMutex);
257 p->mh_number = ++block;
258 debugMemSize += size;
260 if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
262 debugmem_list_add(p);
264 xmlMutexUnlock(xmlMemMutex);
267 xmlGenericError(xmlGenericErrorContext,
268 "Malloc(%d) Ok\n",size);
271 if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
273 ret = HDR_2_CLIENT(p);
275 if (xmlMemTraceBlockAt == ret) {
276 xmlGenericError(xmlGenericErrorContext,
277 "%p : Malloc(%lu) Ok\n", xmlMemTraceBlockAt,
278 (long unsigned)size);
279 xmlMallocBreakpoint();
288 * @size: an int specifying the size in byte to allocate.
290 * a malloc() equivalent, with logging of the allocation info.
292 * Returns a pointer to the allocated area or NULL in case of lack of memory.
296 xmlMemMalloc(size_t size)
298 return(xmlMallocLoc(size, "none", 0));
303 * @ptr: the initial memory block pointer
304 * @size: an int specifying the size in byte to allocate.
305 * @file: the file name or NULL
306 * @line: the line number
308 * a realloc() equivalent, with logging of the allocation info.
310 * Returns a pointer to the allocated area or NULL in case of lack of memory.
314 xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
317 unsigned long number;
323 return(xmlMallocLoc(size, file, line));
325 if (!xmlMemInitialized) xmlInitMemory();
328 p = CLIENT_2_HDR(ptr);
329 number = p->mh_number;
330 if (xmlMemStopAtBlock == number) xmlMallocBreakpoint();
331 if (p->mh_tag != MEMTAG) {
336 xmlMutexLock(xmlMemMutex);
337 debugMemSize -= p->mh_size;
340 oldsize = p->mh_size;
343 debugmem_list_delete(p);
345 xmlMutexUnlock(xmlMemMutex);
347 tmp = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
353 if (xmlMemTraceBlockAt == ptr) {
354 xmlGenericError(xmlGenericErrorContext,
355 "%p : Realloced(%lu -> %lu) Ok\n",
356 xmlMemTraceBlockAt, (long unsigned)p->mh_size,
357 (long unsigned)size);
358 xmlMallocBreakpoint();
361 p->mh_number = number;
362 p->mh_type = REALLOC_TYPE;
366 xmlMutexLock(xmlMemMutex);
367 debugMemSize += size;
369 if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
371 debugmem_list_add(p);
373 xmlMutexUnlock(xmlMemMutex);
378 xmlGenericError(xmlGenericErrorContext,
379 "Realloced(%d to %d) Ok\n", oldsize, size);
381 return(HDR_2_CLIENT(p));
389 * @ptr: the initial memory block pointer
390 * @size: an int specifying the size in byte to allocate.
392 * a realloc() equivalent, with logging of the allocation info.
394 * Returns a pointer to the allocated area or NULL in case of lack of memory.
398 xmlMemRealloc(void *ptr,size_t size) {
399 return(xmlReallocLoc(ptr, size, "none", 0));
404 * @ptr: the memory block pointer
406 * a free() equivalent, with error checking.
409 xmlMemFree(void *ptr)
420 if (ptr == (void *) -1) {
421 xmlGenericError(xmlGenericErrorContext,
422 "trying to free pointer from freed area\n");
426 if (xmlMemTraceBlockAt == ptr) {
427 xmlGenericError(xmlGenericErrorContext,
428 "%p : Freed()\n", xmlMemTraceBlockAt);
429 xmlMallocBreakpoint();
434 target = (char *) ptr;
436 p = CLIENT_2_HDR(ptr);
437 if (p->mh_tag != MEMTAG) {
441 if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
443 memset(target, -1, p->mh_size);
444 xmlMutexLock(xmlMemMutex);
445 debugMemSize -= p->mh_size;
451 debugmem_list_delete(p);
453 xmlMutexUnlock(xmlMemMutex);
460 xmlGenericError(xmlGenericErrorContext,
461 "Freed(%d) Ok\n", size);
467 xmlGenericError(xmlGenericErrorContext,
468 "xmlMemFree(%lX) error\n", (unsigned long) ptr);
469 xmlMallocBreakpoint();
475 * @str: the initial string pointer
476 * @file: the file name or NULL
477 * @line: the line number
479 * a strdup() equivalent, with logging of the allocation info.
481 * Returns a pointer to the new string or NULL if allocation error occurred.
485 xmlMemStrdupLoc(const char *str, const char *file, int line)
488 size_t size = strlen(str) + 1;
491 if (!xmlMemInitialized) xmlInitMemory();
494 p = (MEMHDR *) malloc(RESERVE_SIZE+size);
500 p->mh_type = STRDUP_TYPE;
503 xmlMutexLock(xmlMemMutex);
504 p->mh_number = ++block;
505 debugMemSize += size;
507 if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
509 debugmem_list_add(p);
511 xmlMutexUnlock(xmlMemMutex);
513 s = (char *) HDR_2_CLIENT(p);
515 if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
521 if (xmlMemTraceBlockAt == s) {
522 xmlGenericError(xmlGenericErrorContext,
523 "%p : Strdup() Ok\n", xmlMemTraceBlockAt);
524 xmlMallocBreakpoint();
535 * @str: the initial string pointer
537 * a strdup() equivalent, with logging of the allocation info.
539 * Returns a pointer to the new string or NULL if allocation error occurred.
543 xmlMemoryStrdup(const char *str) {
544 return(xmlMemStrdupLoc(str, "none", 0));
550 * Provides the amount of memory currently allocated
552 * Returns an int representing the amount of memory allocated.
559 xmlMutexLock(xmlMemMutex);
561 xmlMutexUnlock(xmlMemMutex);
568 * Provides the number of memory areas currently allocated
570 * Returns an int representing the number of blocks
577 xmlMutexLock(xmlMemMutex);
578 res = debugMemBlocks;
579 xmlMutexUnlock(xmlMemMutex);
586 * @fp: a FILE descriptor used as the output file
587 * @p: a memory block header
589 * tries to show some content from the memory block
593 xmlMemContentShow(FILE *fp, MEMHDR *p)
599 fprintf(fp, " NULL");
603 buf = (const char *) HDR_2_CLIENT(p);
605 for (i = 0;i < len;i++) {
606 if (buf[i] == 0) break;
607 if (!isprint((unsigned char) buf[i])) break;
609 if ((i < 4) && ((buf[i] != 0) || (i == 0))) {
614 for (j = 0;(j < len -3) && (j < 40);j += 4) {
615 cur = *((void **) &buf[j]);
616 q = CLIENT_2_HDR(cur);
622 if (k++ > 100) break;
624 if ((p != NULL) && (p == q)) {
625 fprintf(fp, " pointer to #%lu at index %d",
631 } else if ((i == 0) && (buf[i] == 0)) {
634 if (buf[i] == 0) fprintf(fp," \"%.25s\"", buf);
637 for (j = 0;j < i;j++)
638 fprintf(fp,"%c", buf[j]);
647 * @fp: a FILE descriptor used as the output file, if NULL, the result is
648 * written to the file .memorylist
649 * @nbBytes: the amount of memory to dump
651 * the last nbBytes of memory allocated and not freed, useful for dumping
652 * the memory left allocated between two places at runtime.
656 xmlMemDisplayLast(FILE *fp, long nbBytes)
669 fp = fopen(".memorylist", "w");
675 fprintf(fp," Last %li MEMORY ALLOCATED : %lu, MAX was %lu\n",
676 nbBytes, debugMemSize, debugMaxMemSize);
677 fprintf(fp,"BLOCK NUMBER SIZE TYPE\n");
679 xmlMutexLock(xmlMemMutex);
681 while ((p) && (nbBytes > 0)) {
682 fprintf(fp,"%-5u %6lu %6lu ",idx++,p->mh_number,
683 (unsigned long)p->mh_size);
684 switch (p->mh_type) {
685 case STRDUP_TYPE:fprintf(fp,"strdup() in ");break;
686 case MALLOC_TYPE:fprintf(fp,"malloc() in ");break;
687 case REALLOC_TYPE:fprintf(fp,"realloc() in ");break;
688 case MALLOC_ATOMIC_TYPE:fprintf(fp,"atomicmalloc() in ");break;
689 case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break;
691 fprintf(fp,"Unknown memory block, may be corrupted");
692 xmlMutexUnlock(xmlMemMutex);
697 if (p->mh_file != NULL) fprintf(fp,"%s(%u)", p->mh_file, p->mh_line);
698 if (p->mh_tag != MEMTAG)
699 fprintf(fp," INVALID");
702 xmlMemContentShow(fp, p);
707 nbBytes -= (unsigned long)p->mh_size;
710 xmlMutexUnlock(xmlMemMutex);
712 fprintf(fp,"Memory list not compiled (MEM_LIST not defined !)\n");
720 * @fp: a FILE descriptor used as the output file, if NULL, the result is
721 * written to the file .memorylist
723 * show in-extenso the memory blocks allocated
727 xmlMemDisplay(FILE *fp)
733 #if defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME)
742 fp = fopen(".memorylist", "w");
748 #if defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME)
749 currentTime = time(NULL);
750 tstruct = localtime(¤tTime);
751 strftime(buf, sizeof(buf) - 1, "%I:%M:%S %p", tstruct);
752 fprintf(fp," %s\n\n", buf);
756 fprintf(fp," MEMORY ALLOCATED : %lu, MAX was %lu\n",
757 debugMemSize, debugMaxMemSize);
758 fprintf(fp,"BLOCK NUMBER SIZE TYPE\n");
760 xmlMutexLock(xmlMemMutex);
763 fprintf(fp,"%-5u %6lu %6lu ",idx++,p->mh_number,
764 (unsigned long)p->mh_size);
765 switch (p->mh_type) {
766 case STRDUP_TYPE:fprintf(fp,"strdup() in ");break;
767 case MALLOC_TYPE:fprintf(fp,"malloc() in ");break;
768 case REALLOC_TYPE:fprintf(fp,"realloc() in ");break;
769 case MALLOC_ATOMIC_TYPE:fprintf(fp,"atomicmalloc() in ");break;
770 case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break;
772 fprintf(fp,"Unknown memory block, may be corrupted");
773 xmlMutexUnlock(xmlMemMutex);
778 if (p->mh_file != NULL) fprintf(fp,"%s(%u)", p->mh_file, p->mh_line);
779 if (p->mh_tag != MEMTAG)
780 fprintf(fp," INVALID");
783 xmlMemContentShow(fp, p);
790 xmlMutexUnlock(xmlMemMutex);
792 fprintf(fp,"Memory list not compiled (MEM_LIST not defined !)\n");
800 static void debugmem_list_add(MEMHDR *p)
802 p->mh_next = memlist;
804 if (memlist) memlist->mh_prev = p;
806 #ifdef MEM_LIST_DEBUG
812 static void debugmem_list_delete(MEMHDR *p)
815 p->mh_next->mh_prev = p->mh_prev;
817 p->mh_prev->mh_next = p->mh_next;
818 else memlist = p->mh_next;
819 #ifdef MEM_LIST_DEBUG
828 * debugmem_tag_error:
830 * internal error function.
833 static void debugmem_tag_error(void *p)
835 xmlGenericError(xmlGenericErrorContext,
836 "Memory tag error occurs :%p \n\t bye\n", p);
839 xmlMemDisplay(stderr);
844 static FILE *xmlMemoryDumpFile = NULL;
849 * @fp: a FILE descriptor used as the output file
850 * @nr: number of entries to dump
852 * show a show display of the memory allocated, and dump
853 * the @nr last allocated areas which were not freed
857 xmlMemShow(FILE *fp, int nr ATTRIBUTE_UNUSED)
864 fprintf(fp," MEMORY ALLOCATED : %lu, MAX was %lu\n",
865 debugMemSize, debugMaxMemSize);
867 xmlMutexLock(xmlMemMutex);
869 fprintf(fp,"NUMBER SIZE TYPE WHERE\n");
871 while ((p) && nr > 0) {
872 fprintf(fp,"%6lu %6lu ",p->mh_number,(unsigned long)p->mh_size);
873 switch (p->mh_type) {
874 case STRDUP_TYPE:fprintf(fp,"strdup() in ");break;
875 case MALLOC_TYPE:fprintf(fp,"malloc() in ");break;
876 case MALLOC_ATOMIC_TYPE:fprintf(fp,"atomicmalloc() in ");break;
877 case REALLOC_TYPE:fprintf(fp,"realloc() in ");break;
878 case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break;
879 default:fprintf(fp," ??? in ");break;
881 if (p->mh_file != NULL)
882 fprintf(fp,"%s(%u)", p->mh_file, p->mh_line);
883 if (p->mh_tag != MEMTAG)
884 fprintf(fp," INVALID");
885 xmlMemContentShow(fp, p);
891 xmlMutexUnlock(xmlMemMutex);
892 #endif /* MEM_LIST */
898 * Dump in-extenso the memory blocks allocated to the file .memorylist
907 if (debugMaxMemSize == 0)
909 dump = fopen(".memdump", "w");
911 xmlMemoryDumpFile = stderr;
912 else xmlMemoryDumpFile = dump;
914 xmlMemDisplay(xmlMemoryDumpFile);
916 if (dump != NULL) fclose(dump);
917 #endif /* MEM_LIST */
921 /****************************************************************
923 * Initialization Routines *
925 ****************************************************************/
930 * Initialize the memory layer.
932 * Returns 0 on success
941 xmlGenericError(xmlGenericErrorContext,
942 "xmlInitMemory()\n");
945 This is really not good code (see Bug 130419). Suggestions for
946 improvement will be welcome!
948 if (xmlMemInitialized) return(-1);
949 xmlMemInitialized = 1;
950 xmlMemMutex = xmlNewMutex();
953 breakpoint = getenv("XML_MEM_BREAKPOINT");
954 if (breakpoint != NULL) {
955 sscanf(breakpoint, "%ud", &xmlMemStopAtBlock);
959 breakpoint = getenv("XML_MEM_TRACE");
960 if (breakpoint != NULL) {
961 sscanf(breakpoint, "%p", &xmlMemTraceBlockAt);
966 xmlGenericError(xmlGenericErrorContext,
967 "xmlInitMemory() Ok\n");
975 * Free up all the memory allocated by the library for its own
976 * use. This should not be called by user level code.
979 xmlCleanupMemory(void) {
981 xmlGenericError(xmlGenericErrorContext,
982 "xmlCleanupMemory()\n");
984 if (xmlMemInitialized == 0)
987 xmlFreeMutex(xmlMemMutex);
989 xmlMemInitialized = 0;
991 xmlGenericError(xmlGenericErrorContext,
992 "xmlCleanupMemory() Ok\n");
998 * @freeFunc: the free() function to use
999 * @mallocFunc: the malloc() function to use
1000 * @reallocFunc: the realloc() function to use
1001 * @strdupFunc: the strdup() function to use
1003 * Override the default memory access functions with a new set
1004 * This has to be called before any other libxml routines !
1006 * Should this be blocked if there was already some allocations
1009 * Returns 0 on success
1012 xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
1013 xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc) {
1015 xmlGenericError(xmlGenericErrorContext,
1018 if (freeFunc == NULL)
1020 if (mallocFunc == NULL)
1022 if (reallocFunc == NULL)
1024 if (strdupFunc == NULL)
1027 xmlMalloc = mallocFunc;
1028 xmlMallocAtomic = mallocFunc;
1029 xmlRealloc = reallocFunc;
1030 xmlMemStrdup = strdupFunc;
1032 xmlGenericError(xmlGenericErrorContext,
1033 "xmlMemSetup() Ok\n");
1040 * @freeFunc: place to save the free() function in use
1041 * @mallocFunc: place to save the malloc() function in use
1042 * @reallocFunc: place to save the realloc() function in use
1043 * @strdupFunc: place to save the strdup() function in use
1045 * Provides the memory access functions set currently in use
1047 * Returns 0 on success
1050 xmlMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc,
1051 xmlReallocFunc *reallocFunc, xmlStrdupFunc *strdupFunc) {
1052 if (freeFunc != NULL) *freeFunc = xmlFree;
1053 if (mallocFunc != NULL) *mallocFunc = xmlMalloc;
1054 if (reallocFunc != NULL) *reallocFunc = xmlRealloc;
1055 if (strdupFunc != NULL) *strdupFunc = xmlMemStrdup;
1061 * @freeFunc: the free() function to use
1062 * @mallocFunc: the malloc() function to use
1063 * @mallocAtomicFunc: the malloc() function to use for atomic allocations
1064 * @reallocFunc: the realloc() function to use
1065 * @strdupFunc: the strdup() function to use
1067 * Override the default memory access functions with a new set
1068 * This has to be called before any other libxml routines !
1069 * The mallocAtomicFunc is specialized for atomic block
1070 * allocations (i.e. of areas useful for garbage collected memory allocators
1072 * Should this be blocked if there was already some allocations
1075 * Returns 0 on success
1078 xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
1079 xmlMallocFunc mallocAtomicFunc, xmlReallocFunc reallocFunc,
1080 xmlStrdupFunc strdupFunc) {
1082 xmlGenericError(xmlGenericErrorContext,
1083 "xmlGcMemSetup()\n");
1085 if (freeFunc == NULL)
1087 if (mallocFunc == NULL)
1089 if (mallocAtomicFunc == NULL)
1091 if (reallocFunc == NULL)
1093 if (strdupFunc == NULL)
1096 xmlMalloc = mallocFunc;
1097 xmlMallocAtomic = mallocAtomicFunc;
1098 xmlRealloc = reallocFunc;
1099 xmlMemStrdup = strdupFunc;
1101 xmlGenericError(xmlGenericErrorContext,
1102 "xmlGcMemSetup() Ok\n");
1109 * @freeFunc: place to save the free() function in use
1110 * @mallocFunc: place to save the malloc() function in use
1111 * @mallocAtomicFunc: place to save the atomic malloc() function in use
1112 * @reallocFunc: place to save the realloc() function in use
1113 * @strdupFunc: place to save the strdup() function in use
1115 * Provides the memory access functions set currently in use
1116 * The mallocAtomicFunc is specialized for atomic block
1117 * allocations (i.e. of areas useful for garbage collected memory allocators
1119 * Returns 0 on success
1122 xmlGcMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc,
1123 xmlMallocFunc *mallocAtomicFunc, xmlReallocFunc *reallocFunc,
1124 xmlStrdupFunc *strdupFunc) {
1125 if (freeFunc != NULL) *freeFunc = xmlFree;
1126 if (mallocFunc != NULL) *mallocFunc = xmlMalloc;
1127 if (mallocAtomicFunc != NULL) *mallocAtomicFunc = xmlMallocAtomic;
1128 if (reallocFunc != NULL) *reallocFunc = xmlRealloc;
1129 if (strdupFunc != NULL) *strdupFunc = xmlMemStrdup;
1133 #define bottom_xmlmemory
1134 #include "elfgcchack.h"