aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-filter.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2000-10-17 17:45:38 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-10-17 17:45:38 +0800
commita8cd947d9bed93078a5edd6a2f483748778422ae (patch)
treeecb7faebf2d79b9c3132cb805533bb951f5604ff /camel/camel-mime-filter.c
parent97be61b4787ccb3b52a34e625cb5f49c67ace6fe (diff)
downloadgsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar.gz
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar.bz2
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar.lz
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar.xz
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar.zst
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.zip
Added some malloc check debugging stuff.
2000-10-17 Not Zed <NotZed@HelixCode.com> * camel-mime-filter.c: Added some malloc check debugging stuff. * camel-mime-parser.c (struct _header_scan_state): Removed top_part, top_start, and pending. I can't even remember why they were there, and they're not used anymore. * camel-mime-filter-basic.c (filter): Forgot to up the space here too. 2000-10-14 Not Zed <NotZed@HelixCode.com> * camel-mime-filter-basic.c (complete): Ok, so we hit a fixme, 3x just wasn't enough for some sequences. svn path=/trunk/; revision=5962
Diffstat (limited to 'camel/camel-mime-filter.c')
-rw-r--r--camel/camel-mime-filter.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/camel/camel-mime-filter.c b/camel/camel-mime-filter.c
index 678d450af2..9a81dfb452 100644
--- a/camel/camel-mime-filter.c
+++ b/camel/camel-mime-filter.c
@@ -20,6 +20,13 @@
#include "camel-mime-filter.h"
+/*#define MALLOC_CHECK */ /* for some malloc checking, requires mcheck enabled */
+
+/* only suitable for glibc */
+#ifdef MALLOC_CHECK
+#include <mcheck.h>
+#endif
+
struct _CamelMimeFilterPrivate {
char *inbuf;
size_t inlen;
@@ -108,6 +115,28 @@ camel_mime_filter_new (void)
return new;
}
+#ifdef MALLOC_CHECK
+static void
+checkmem(void *p)
+{
+ if (p) {
+ int status = mprobe(p);
+
+ switch (status) {
+ case MCHECK_HEAD:
+ printf("Memory underrun at %p\n", p);
+ abort();
+ case MCHECK_TAIL:
+ printf("Memory overrun at %p\n", p);
+ abort();
+ case MCHECK_FREE:
+ printf("Double free %p\n", p);
+ abort();
+ }
+ }
+}
+#endif
+
static void filter_run(CamelMimeFilter *f,
char *in, size_t len, size_t prespace,
char **out, size_t *outlen, size_t *outprespace,
@@ -117,6 +146,10 @@ static void filter_run(CamelMimeFilter *f,
{
struct _CamelMimeFilterPrivate *p;
+#ifdef MALLOC_CHECK
+ checkmem(f->outreal);
+ checkmem(f->backbuf);
+#endif
/*
here we take a performance hit, if the input buffer doesn't
have the pre-space required. We make a buffer that does ...
@@ -136,6 +169,11 @@ static void filter_run(CamelMimeFilter *f,
prespace = p->inlen - len;
}
+#ifdef MALLOC_CHECK
+ checkmem(f->outreal);
+ checkmem(f->backbuf);
+#endif
+
/* preload any backed up data */
if (f->backlen > 0) {
memcpy(in-f->backlen, f->backbuf, f->backlen);
@@ -146,6 +184,12 @@ static void filter_run(CamelMimeFilter *f,
}
filterfunc(f, in, len, prespace, out, outlen, outprespace);
+
+#ifdef MALLOC_CHECK
+ checkmem(f->outreal);
+ checkmem(f->backbuf);
+#endif
+
}
void camel_mime_filter_filter(CamelMimeFilter *f,