aboutsummaryrefslogtreecommitdiffstats
path: root/xmlmemory.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2004-07-02 12:23:44 +0000
committerDaniel Veillard <veillard@src.gnome.org>2004-07-02 12:23:44 +0000
commit529233ccdd43203fd74ec18a1d5a071c122c6e46 (patch)
tree7b1a0387795846c560bbf5fc1c0df2ff543b58cd /xmlmemory.c
parentf93a866079364a006189683eaa07f94c867389d1 (diff)
downloadandroid_external_libxml2-529233ccdd43203fd74ec18a1d5a071c122c6e46.tar.gz
android_external_libxml2-529233ccdd43203fd74ec18a1d5a071c122c6e46.tar.bz2
android_external_libxml2-529233ccdd43203fd74ec18a1d5a071c122c6e46.zip
some updates with memory debugging facilities while messing with libxslt
* xmlmemory.c python/libxml.c python/libxml2-python-api.xml: some updates with memory debugging facilities while messing with libxslt python bindings Daniel
Diffstat (limited to 'xmlmemory.c')
-rw-r--r--xmlmemory.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/xmlmemory.c b/xmlmemory.c
index a0ed5f4e..4993351a 100644
--- a/xmlmemory.c
+++ b/xmlmemory.c
@@ -310,6 +310,9 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
{
MEMHDR *p;
unsigned long number;
+#ifdef DEBUG_MEMORY
+ size_t oldsize;
+#endif
if (ptr == NULL)
return(xmlMallocLoc(size, file, line));
@@ -326,6 +329,9 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
p->mh_tag = ~MEMTAG;
xmlMutexLock(xmlMemMutex);
debugMemSize -= p->mh_size;
+#ifdef DEBUG_MEMORY
+ oldsize = p->mh_size;
+#endif
#ifdef MEM_LIST
debugmem_list_delete(p);
#endif
@@ -357,6 +363,10 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
TEST_POINT
+#ifdef DEBUG_MEMORY
+ xmlGenericError(xmlGenericErrorContext,
+ "Realloced(%d to %d) Ok\n", oldsize, size);
+#endif
return(HDR_2_CLIENT(p));
error:
@@ -389,6 +399,9 @@ xmlMemFree(void *ptr)
{
MEMHDR *p;
char *target;
+#ifdef DEBUG_MEMORY
+ size_t size;
+#endif
if (ptr == (void *) -1) {
xmlGenericError(xmlGenericErrorContext,
@@ -415,6 +428,9 @@ xmlMemFree(void *ptr)
memset(target, -1, p->mh_size);
xmlMutexLock(xmlMemMutex);
debugMemSize -= p->mh_size;
+#ifdef DEBUG_MEMORY
+ size = p->mh_size;
+#endif
#ifdef MEM_LIST
debugmem_list_delete(p);
#endif
@@ -424,6 +440,11 @@ xmlMemFree(void *ptr)
TEST_POINT
+#ifdef DEBUG_MEMORY
+ xmlGenericError(xmlGenericErrorContext,
+ "Freed(%d) Ok\n", size);
+#endif
+
return;
error:
@@ -619,12 +640,15 @@ xmlMemDisplay(FILE *fp)
switch (p->mh_type) {
case STRDUP_TYPE:fprintf(fp,"strdup() in ");break;
case MALLOC_TYPE:fprintf(fp,"malloc() in ");break;
- case REALLOC_TYPE:fprintf(fp,"realloc() in ");break;
+ case REALLOC_TYPE:fprintf(fp,"realloc() in ");break;
case MALLOC_ATOMIC_TYPE:fprintf(fp,"atomicmalloc() in ");break;
- case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break;
- default:fprintf(fp," ??? in ");break;
+ case REALLOC_ATOMIC_TYPE:fprintf(fp,"atomicrealloc() in ");break;
+ default:
+ fprintf(fp,"Unknow memory block, corruped maybe");
+ xmlMutexUnlock(xmlMemMutex);
+ return;
}
- if (p->mh_file != NULL) fprintf(fp,"%s(%d)", p->mh_file, p->mh_line);
+ if (p->mh_file != NULL) fprintf(fp,"%s(%d)", p->mh_file, p->mh_line);
if (p->mh_tag != MEMTAG)
fprintf(fp," INVALID");
nb++;