From 1407a32f6c1edcfb198f1d95b0519d99aa03a5e9 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Tue, 1 Jan 2008 18:04:50 -0500 Subject: [PATCH] Only include xdump() if DEBUG is defined. --- src/mem.c | 8 ++++++++ src/mem.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/mem.c b/src/mem.c index 2e48c3eb..667a0949 100644 --- a/src/mem.c +++ b/src/mem.c @@ -33,7 +33,9 @@ #include "mem.h" static struct memlist_s *memlist; +#ifdef DEBUG static size_t allocations, deallocations; +#endif static struct memlist_s *memlist_remove(struct memlist_s *list, struct memlist_s *r) { @@ -46,7 +48,9 @@ static struct memlist_s *memlist_remove(struct memlist_s *list, struct memlist_s p = m->next; free(m); +#ifdef DEBUG deallocations++; +#endif if (last) { if (p) @@ -70,7 +74,9 @@ static struct memlist_s *memlist_remove(struct memlist_s *list, struct memlist_s static struct memlist_s *memlist_prepend(struct memlist_s *list, struct memlist_s *p) { +#ifdef DEBUG allocations++; +#endif p->next = list; return p; } @@ -211,6 +217,7 @@ void xpanic(void) xfree(m->ptr); } +#ifdef DEBUG void xdump(void) { struct memlist_s *m; @@ -224,3 +231,4 @@ void xdump(void) fprintf(stderr, "Total unfreed: %i bytes, allocations: %i, deallocations: %i\n", total, allocations, deallocations); } +#endif diff --git a/src/mem.h b/src/mem.h index f5fee610..c26581b0 100644 --- a/src/mem.h +++ b/src/mem.h @@ -36,7 +36,9 @@ void *xrealloc(void *ptr, size_t size) __attribute__ ((visibility ("hidden"))); char *xstrdup(const char *str) __attribute__ ((visibility ("hidden"))); void *xcalloc(size_t nmemb, size_t size) __attribute__ ((visibility ("hidden"))); void xpanic(void) __attribute__ ((visibility ("hidden"))); +#ifdef DEBUG void xdump(void) __attribute__ ((visibility ("hidden"))); +#endif #ifdef __cplusplus } -- 2.11.4.GIT