From a973415f0e175aadc4b004c0de36e3caf5618cb8 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Tue, 10 May 2011 16:27:04 +0200 Subject: [PATCH] xalloc: do not implement xfree() function in non-debug mode. all it does is add another function call in that situation. --- src/xalloc.c | 3 ++- src/xalloc.h | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/xalloc.c b/src/xalloc.c index cb2d057..f81e39e 100644 --- a/src/xalloc.c +++ b/src/xalloc.c @@ -8,7 +8,6 @@ * (at your option) any later version. */ -#include #include #include #include "util.h" @@ -84,8 +83,10 @@ void* xmemdup(const void *src, size_t size) { return dest; } +#ifdef __DEBUG__ void xfree(void *ptr) { CHECK_INPUT(ptr, "xfree"); free(ptr); } +#endif /* __DEBUG__ */ diff --git a/src/xalloc.h b/src/xalloc.h index fe1900c..72724e5 100644 --- a/src/xalloc.h +++ b/src/xalloc.h @@ -11,7 +11,7 @@ #ifndef __XALLOC_H #define __XALLOC_H -#include +#include void* xmalloc(size_t); @@ -23,6 +23,10 @@ char* xstrdup(const char *); void* xmemdup(const void *, size_t); +#ifdef __DEBUG__ void xfree(void *); +#else +#define xfree free +#endif /* __DEBUG__ */ #endif /* __XALLOC_H */