21#ifdef DEBUG_MEMORY_LOCATION
48#if !defined(LIBXML_THREAD_ENABLED) && !defined(LIBXML_THREAD_ALLOC_ENABLED)
69#define MALLOC_ATOMIC_TYPE 4
70#define REALLOC_ATOMIC_TYPE 5
89#define ALIGN_SIZE sizeof(double)
91#define HDR_SIZE sizeof(MEMHDR)
92#define RESERVE_SIZE (((HDR_SIZE + (ALIGN_SIZE-1)) \
93 / ALIGN_SIZE ) * ALIGN_SIZE)
95#define MAX_SIZE_T ((size_t)-1)
97#define CLIENT_2_HDR(a) ((void *) (((char *) (a)) - RESERVE_SIZE))
98#define HDR_2_CLIENT(a) ((void *) (((char *) (a)) + RESERVE_SIZE))
110static void debugmem_list_add(
MEMHDR *);
111static void debugmem_list_delete(
MEMHDR *);
113#define Mem_Tag_Err(a) debugmem_tag_error(a);
156 "xmlMallocLoc : Unsigned overflow\n");
164 "xmlMallocLoc : Out of free space\n");
178 debugmem_list_add(
p);
189 (
long unsigned)
size);
221 "xmlMallocAtomicLoc : Unsigned overflow\n");
229 "xmlMallocAtomicLoc : Out of free space\n");
243 debugmem_list_add(
p);
254 (
long unsigned)
size);
313 debugmem_list_delete(
p);
319 "xmlReallocLoc : Unsigned overflow\n");
331 "%p : Realloced(%lu -> %lu) Ok\n",
333 (
long unsigned)
size);
347 debugmem_list_add(
p);
389 if (
ptr == (
void *) -1) {
391 "trying to free pointer from freed area\n");
417 debugmem_list_delete(
p);
429 "xmlMemFree(%p) error\n",
ptr);
457 "xmlMemStrdupLoc : Unsigned overflow\n");
476 debugmem_list_add(
p);
590 fp =
fopen(
".memorylist",
"w");
596 fprintf(fp,
" Last %li MEMORY ALLOCATED : %lu, MAX was %lu\n",
598 fprintf(fp,
"BLOCK NUMBER SIZE TYPE\n");
602 while ((
p) && (nbBytes > 0)) {
604 (
unsigned long)
p->mh_size);
605 switch (
p->mh_type) {
612 fprintf(fp,
"Unknown memory block, may be corrupted");
618 if (
p->mh_file !=
NULL)
fprintf(fp,
"%s(%u)",
p->mh_file,
p->mh_line);
624 nbBytes -= (
unsigned long)
p->mh_size;
629 fprintf(fp,
"Memory list not compiled (MEM_LIST not defined !)\n");
657 fp =
fopen(
".memorylist",
"w");
669 fprintf(fp,
" MEMORY ALLOCATED : %lu, MAX was %lu\n",
671 fprintf(fp,
"BLOCK NUMBER SIZE TYPE\n");
677 (
unsigned long)
p->mh_size);
678 switch (
p->mh_type) {
685 fprintf(fp,
"Unknown memory block, may be corrupted");
691 if (
p->mh_file !=
NULL)
fprintf(fp,
"%s(%u)",
p->mh_file,
p->mh_line);
701 fprintf(fp,
"Memory list not compiled (MEM_LIST not defined !)\n");
709static void debugmem_list_add(
MEMHDR *
p)
711 p->mh_next = memlist;
713 if (memlist) memlist->mh_prev =
p;
717static void debugmem_list_delete(
MEMHDR *
p)
720 p->mh_next->mh_prev =
p->mh_prev;
722 p->mh_prev->mh_next =
p->mh_next;
723 else memlist =
p->mh_next;
737 "Memory tag error occurs :%p \n\t bye\n",
p);
745static FILE *xmlMemoryDumpFile =
NULL;
765 fprintf(fp,
" MEMORY ALLOCATED : %lu, MAX was %lu\n",
770 fprintf(fp,
"NUMBER SIZE TYPE WHERE\n");
772 while ((
p) &&
nr > 0) {
773 fprintf(fp,
"%6lu %6lu ",
p->mh_number,(
unsigned long)
p->mh_size);
774 switch (
p->mh_type) {
780 default:
fprintf(fp,
" ??? in ");
break;
782 if (
p->mh_file !=
NULL)
783 fprintf(fp,
"%s(%u)",
p->mh_file,
p->mh_line);
811 xmlMemoryDumpFile =
stderr;
812 else xmlMemoryDumpFile =
dump;
888#if !defined(LIBXML_THREAD_ENABLED) || !defined(_WIN32)
911 if (freeFunc ==
NULL)
913 if (mallocFunc ==
NULL)
915 if (reallocFunc ==
NULL)
917 if (strdupFunc ==
NULL)
970 if (freeFunc ==
NULL)
972 if (mallocFunc ==
NULL)
974 if (mallocAtomicFunc ==
NULL)
976 if (reallocFunc ==
NULL)
978 if (strdupFunc ==
NULL)
char *CDECL getenv(const char *name)
int CDECL fclose(FILE *file)
int WINAPIV fprintf(FILE *file, const char *format,...)
FILE *CDECL fopen(const char *path, const char *mode)
_ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl sscanf(const char *, const char *,...) __WINE_CRT_SCANF_ATTR(2
_ACRTIMP size_t __cdecl strlen(const char *)
_ACRTIMP size_t __cdecl strftime(char *, size_t, const char *, const struct tm *)
static struct tm * localtime(const time_t *t)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum const GLvoid * addr
XMLPUBFUN void xmlMutexLock(xmlMutexPtr tok)
XMLPUBFUN void xmlMutexUnlock(xmlMutexPtr tok)
static unsigned int number
static void dump(const void *ptr, unsigned len)
XML_HIDDEN void xmlCleanupMutex(xmlMutexPtr mutex)
XML_HIDDEN void xmlInitMutex(xmlMutexPtr mutex)
void * xmlGenericErrorContext
xmlReallocFunc xmlRealloc
xmlGenericErrorFunc xmlGenericError
xmlMallocFunc xmlMallocAtomic
xmlStrdupFunc xmlMemStrdup
XML_GLOBALS_PARSER XMLPUBFUN void xmlInitParser(void)
void * xmlMallocAtomicLoc(size_t size, const char *file, int line)
void xmlMallocBreakpoint(void)
void xmlMemFree(void *ptr)
void * xmlMemMalloc(size_t size)
#define MALLOC_ATOMIC_TYPE
void * xmlMemRealloc(void *ptr, size_t size)
void xmlCleanupMemoryInternal(void)
static xmlMutex xmlMemMutex
static unsigned int block
int xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc, xmlMallocFunc mallocAtomicFunc, xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc)
#define REALLOC_ATOMIC_TYPE
void xmlMemDisplayLast(FILE *fp, long nbBytes)
void xmlCleanupMemory(void)
void * xmlMallocLoc(size_t size, const char *file, int line)
static unsigned long debugMemBlocks
static unsigned int xmlMemStopAtBlock
static void debugmem_tag_error(void *addr)
size_t xmlMemSize(void *ptr)
char * xmlMemoryStrdup(const char *str)
char * xmlMemStrdupLoc(const char *str, const char *file, int line)
int xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc, xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc)
int xmlGcMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc, xmlMallocFunc *mallocAtomicFunc, xmlReallocFunc *reallocFunc, xmlStrdupFunc *strdupFunc)
int xmlMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc, xmlReallocFunc *reallocFunc, xmlStrdupFunc *strdupFunc)
static unsigned long debugMemSize
void xmlInitMemoryInternal(void)
static void * xmlMemTraceBlockAt
void xmlMemShow(FILE *fp, int nr ATTRIBUTE_UNUSED)
void * xmlReallocLoc(void *ptr, size_t size, const char *file, int line)
static unsigned long debugMaxMemSize
void xmlMemDisplay(FILE *fp)
void *(* xmlReallocFunc)(void *mem, size_t size)
char *(* xmlStrdupFunc)(const char *str)
void(* xmlFreeFunc)(void *mem)