aboutsummaryrefslogtreecommitdiffstats
path: root/xmlmemory.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>1999-12-29 12:49:06 +0000
committerDaniel Veillard <veillard@src.gnome.org>1999-12-29 12:49:06 +0000
commit5e5c62351f88ed07e3a67cf3735bf3ae290eb03d (patch)
tree490f0deb75cfcaa11490dbe96f12e826fea1a305 /xmlmemory.c
parentbe849cf33f7e8f6c5ff60d753f1a6a850a33ca8e (diff)
downloadandroid_external_libxml2-5e5c62351f88ed07e3a67cf3735bf3ae290eb03d.tar.gz
android_external_libxml2-5e5c62351f88ed07e3a67cf3735bf3ae290eb03d.tar.bz2
android_external_libxml2-5e5c62351f88ed07e3a67cf3735bf3ae290eb03d.zip
- Push mode for the HTML parser (new calls)
- Improved the memory debugger to provide content informations - cleanups, last known mem leak killed Daniel
Diffstat (limited to 'xmlmemory.c')
-rw-r--r--xmlmemory.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/xmlmemory.c b/xmlmemory.c
index 2d46f385..1013e7e6 100644
--- a/xmlmemory.c
+++ b/xmlmemory.c
@@ -25,6 +25,9 @@
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
#include "xmlmemory.h"
@@ -368,6 +371,59 @@ xmlMemUsed(void) {
return(debugMemSize);
}
+#ifdef MEM_LIST
+/**
+ * xmlMemContentShow:
+ * @fp: a FILE descriptor used as the output file
+ * @p: a memory block header
+ *
+ * tries to show some content from the memory block
+ */
+
+void
+xmlMemContentShow(FILE *fp, MEMHDR *p)
+{
+ int i,j,len = p->mh_size;
+ const char *buf = HDR_2_CLIENT(p);
+
+ for (i = 0;i < len;i++) {
+ if (buf[i] == 0) break;
+ if (!isprint(buf[i])) break;
+ }
+ if ((i < 4) && ((buf[i] != 0) || (i == 0))) {
+ if (len >= 4) {
+ MEMHDR *q;
+ void *cur;
+
+ for (j = 0;j < len -3;j += 4) {
+ cur = *((void **) &buf[j]);
+ q = CLIENT_2_HDR(cur);
+ p = memlist;
+ while (p != NULL) {
+ if (p == q) break;
+ p = p->mh_next;
+ }
+ if (p == q) {
+ fprintf(fp, " pointer to #%lu at index %d",
+ p->mh_number, j);
+ return;
+ }
+ }
+ }
+ } else if ((i == 0) && (buf[i] == 0)) {
+ fprintf(fp," null");
+ } else {
+ if (buf[i] == 0) fprintf(fp," \"%.25s\"", buf);
+ else {
+ fprintf(fp," [");
+ for (j = 0;j < i;j++)
+ fprintf(fp,"%c", buf[j]);
+ fprintf(fp,"]");
+ }
+ }
+}
+#endif
+
/**
* xmlMemShow:
* @fp: a FILE descriptor used as the output file
@@ -403,6 +459,7 @@ xmlMemShow(FILE *fp, int nr)
fprintf(fp,"%s(%d)", p->mh_file, p->mh_line);
if (p->mh_tag != MEMTAG)
fprintf(fp," INVALID");
+ xmlMemContentShow(fp, p);
fprintf(fp,"\n");
nr--;
p = p->mh_next;
@@ -453,6 +510,7 @@ xmlMemDisplay(FILE *fp)
if (p->mh_file != NULL) fprintf(fp,"%s(%d)", p->mh_file, p->mh_line);
if (p->mh_tag != MEMTAG)
fprintf(fp," INVALID");
+ xmlMemContentShow(fp, p);
fprintf(fp,"\n");
p = p->mh_next;
}