Archived
1
0
Fork 0

xalloc: do not implement xfree() function in non-debug mode.

all it does is add another function call in that situation.
This commit is contained in:
Henrik Hautakoski 2011-05-10 16:27:04 +02:00
parent e0f29b6a45
commit a973415f0e
2 changed files with 7 additions and 2 deletions

View file

@ -8,7 +8,6 @@
* (at your option) any later version.
*/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#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__ */

View file

@ -11,7 +11,7 @@
#ifndef __XALLOC_H
#define __XALLOC_H
#include <stddef.h>
#include <stdlib.h>
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 */