12 #ifdef HAVE_SYS_TYPES_H 40 #ifdef DEBUG_MEMORY_LOCATION 65 #if !defined(LIBXML_THREAD_ENABLED) && !defined(LIBXML_THREAD_ALLOC_ENABLED) 84 #define REALLOC_TYPE 2 86 #define MALLOC_ATOMIC_TYPE 4 87 #define REALLOC_ATOMIC_TYPE 5 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) 112 #define MAX_SIZE_T ((size_t)-1) 114 #define CLIENT_2_HDR(a) ((void *) (((char *) (a)) - RESERVE_SIZE)) 115 #define HDR_2_CLIENT(a) ((void *) (((char *) (a)) + RESERVE_SIZE)) 127 static void debugmem_list_add(
MEMHDR *);
128 static void debugmem_list_delete(
MEMHDR *);
130 #define Mem_Tag_Err(a) debugmem_tag_error(a); 170 "Malloc(%d)\n",
size);
177 "xmlMallocLoc : Unsigned overflow\n");
186 "xmlMallocLoc : Out of free space\n");
201 debugmem_list_add(
p);
207 "Malloc(%d) Ok\n",
size);
217 (
long unsigned)
size);
246 "Malloc(%d)\n",
size);
253 "xmlMallocAtomicLoc : Unsigned overflow\n");
262 "xmlMallocAtomicLoc : Out of free space\n");
277 debugmem_list_add(
p);
283 "Malloc(%d) Ok\n",
size);
293 (
long unsigned)
size);
355 oldsize =
p->mh_size;
358 debugmem_list_delete(
p);
364 "xmlReallocLoc : Unsigned overflow\n");
377 "%p : Realloced(%lu -> %lu) Ok\n",
379 (
long unsigned)
size);
393 debugmem_list_add(
p);
401 "Realloced(%d to %d) Ok\n", oldsize,
size);
442 if (
ptr == (
void *) -1) {
444 "trying to free pointer from freed area\n");
473 debugmem_list_delete(
p);
483 "Freed(%d) Ok\n",
size);
490 "xmlMemFree(%p) error\n",
ptr);
518 "xmlMemStrdupLoc : Unsigned overflow\n");
538 debugmem_list_add(
p);
635 if (
buf[
i] == 0)
break;
638 if ((
i < 4) && ((
buf[
i] != 0) || (
i == 0))) {
643 for (
j = 0;(
j <
len -3) && (
j < 40);
j += 4) {
651 if (
k++ > 100)
break;
654 fprintf(fp,
" pointer to #%lu at index %d",
660 }
else if ((
i == 0) && (
buf[
i] == 0)) {
666 for (
j = 0;
j <
i;
j++)
698 fp =
fopen(
".memorylist",
"w");
704 fprintf(fp,
" Last %li MEMORY ALLOCATED : %lu, MAX was %lu\n",
706 fprintf(fp,
"BLOCK NUMBER SIZE TYPE\n");
710 while ((
p) && (nbBytes > 0)) {
712 (
unsigned long)
p->mh_size);
713 switch (
p->mh_type) {
720 fprintf(fp,
"Unknown memory block, may be corrupted");
726 if (
p->mh_file !=
NULL)
fprintf(fp,
"%s(%u)",
p->mh_file,
p->mh_line);
731 xmlMemContentShow(fp,
p);
736 nbBytes -= (
unsigned long)
p->mh_size;
741 fprintf(fp,
"Memory list not compiled (MEM_LIST not defined !)\n");
762 #if defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME) 771 fp =
fopen(
".memorylist",
"w");
777 #if defined(HAVE_LOCALTIME) && defined(HAVE_STRFTIME) 785 fprintf(fp,
" MEMORY ALLOCATED : %lu, MAX was %lu\n",
787 fprintf(fp,
"BLOCK NUMBER SIZE TYPE\n");
793 (
unsigned long)
p->mh_size);
794 switch (
p->mh_type) {
801 fprintf(fp,
"Unknown memory block, may be corrupted");
807 if (
p->mh_file !=
NULL)
fprintf(fp,
"%s(%u)",
p->mh_file,
p->mh_line);
812 xmlMemContentShow(fp,
p);
821 fprintf(fp,
"Memory list not compiled (MEM_LIST not defined !)\n");
829 static void debugmem_list_add(
MEMHDR *
p)
831 p->mh_next = memlist;
833 if (memlist) memlist->mh_prev =
p;
835 #ifdef MEM_LIST_DEBUG 841 static void debugmem_list_delete(
MEMHDR *
p)
844 p->mh_next->mh_prev =
p->mh_prev;
846 p->mh_prev->mh_next =
p->mh_next;
847 else memlist =
p->mh_next;
848 #ifdef MEM_LIST_DEBUG 865 "Memory tag error occurs :%p \n\t bye\n",
p);
873 static FILE *xmlMemoryDumpFile =
NULL;
893 fprintf(fp,
" MEMORY ALLOCATED : %lu, MAX was %lu\n",
898 fprintf(fp,
"NUMBER SIZE TYPE WHERE\n");
900 while ((
p) &&
nr > 0) {
901 fprintf(fp,
"%6lu %6lu ",
p->mh_number,(
unsigned long)
p->mh_size);
902 switch (
p->mh_type) {
908 default:
fprintf(fp,
" ??? in ");
break;
910 if (
p->mh_file !=
NULL)
911 fprintf(fp,
"%s(%u)",
p->mh_file,
p->mh_line);
914 xmlMemContentShow(fp,
p);
940 xmlMemoryDumpFile =
stderr;
941 else xmlMemoryDumpFile =
dump;
971 "xmlInitMemory()\n");
996 "xmlInitMemory() Ok\n");
1011 "xmlCleanupMemory()\n");
1021 "xmlCleanupMemory() Ok\n");
1047 if (freeFunc ==
NULL)
1049 if (mallocFunc ==
NULL)
1051 if (reallocFunc ==
NULL)
1053 if (strdupFunc ==
NULL)
1062 "xmlMemSetup() Ok\n");
1112 "xmlGcMemSetup()\n");
1114 if (freeFunc ==
NULL)
1116 if (mallocFunc ==
NULL)
1118 if (mallocAtomicFunc ==
NULL)
1120 if (reallocFunc ==
NULL)
1122 if (strdupFunc ==
NULL)
1131 "xmlGcMemSetup() Ok\n");
1162 #define bottom_xmlmemory
static unsigned int block
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
void xmlMemDisplay(FILE *fp)
static int xmlMemInitialized
void(XMLCALL * xmlFreeFunc)(void *mem)
ACPI_SIZE strlen(const char *String)
static void * xmlMemTraceBlockAt
static unsigned long debugMemSize
XMLPUBFUN void XMLCALL xmlMutexUnlock(xmlMutexPtr tok)
#define REALLOC_ATOMIC_TYPE
XMLPUBFUN void XMLCALL xmlMutexLock(xmlMutexPtr tok)
void *(XMLCALL * xmlReallocFunc)(void *mem, size_t size)
int xmlMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc, xmlReallocFunc *reallocFunc, xmlStrdupFunc *strdupFunc)
GLenum GLuint GLenum GLsizei const GLchar * buf
static xmlMutexPtr xmlMemMutex
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static size_t double number
char *(XMLCALL * xmlStrdupFunc)(const char *str)
static unsigned int xmlMemStopAtBlock
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
int xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc, xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
static unsigned long debugMemBlocks
void * xmlMallocLoc(size_t size, const char *file, int line)
int xmlGcMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc, xmlMallocFunc *mallocAtomicFunc, xmlReallocFunc *reallocFunc, xmlStrdupFunc *strdupFunc)
XMLPUBVAR xmlReallocFunc xmlRealloc
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
size_t CDECL strftime(char *str, size_t max, const char *format, const struct tm *mstm)
void * xmlMallocAtomicLoc(size_t size, const char *file, int line)
char * xmlMemoryStrdup(const char *str)
XMLPUBVAR xmlFreeFunc xmlFree
GLdouble GLdouble GLdouble GLdouble q
void xmlMemFree(void *ptr)
char * xmlMemStrdupLoc(const char *str, const char *file, int line)
void xmlCleanupMemory(void)
GLenum const GLvoid * addr
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
XMLPUBFUN void XMLCALL xmlFreeMutex(xmlMutexPtr tok)
int xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc, xmlMallocFunc mallocAtomicFunc, xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc)
XMLPUBVAR xmlStrdupFunc xmlMemStrdup
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
void xmlMemShow(FILE *fp, int nr ATTRIBUTE_UNUSED)
void * xmlReallocLoc(void *ptr, size_t size, const char *file, int line)
XMLPUBVAR xmlMallocFunc xmlMalloc
XMLPUBFUN xmlMutexPtr XMLCALL xmlNewMutex(void)
void xmlMallocBreakpoint(void)
char * strcpy(char *DstString, const char *SrcString)
void * xmlMemRealloc(void *ptr, size_t size)
void xmlMemDisplayLast(FILE *fp, long nbBytes)
static void debugmem_tag_error(void *addr)
static unsigned long debugMaxMemSize
void * xmlMemMalloc(size_t size)
static void dump(const void *ptr, unsigned len)
#define MALLOC_ATOMIC_TYPE
XMLPUBVAR void * xmlGenericErrorContext