From 536256b2daf51860fd8278641a12c46ce0c9dc5d Mon Sep 17 00:00:00 2001 From: thorkill Date: Wed, 1 Jul 2015 19:04:22 +0200 Subject: [PATCH] Added support for cmocka *alloc --- src/xalloc.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/xalloc.h b/src/xalloc.h index 28960fbd..0fe176b4 100644 --- a/src/xalloc.h +++ b/src/xalloc.h @@ -22,7 +22,11 @@ static inline void *xmalloc(size_t n) __attribute__ ((__malloc__)); static inline void *xmalloc(size_t n) { +#ifdef UNIT_TESTING + void *p = test_malloc(n); +#else void *p = malloc(n); +#endif if(!p) abort(); return p; @@ -30,14 +34,22 @@ static inline void *xmalloc(size_t n) { static inline void *xzalloc(size_t n) __attribute__ ((__malloc__)); static inline void *xzalloc(size_t n) { +#ifdef UNIT_TESTING + void *p = test_calloc(1, n); +#else void *p = calloc(1, n); +#endif if(!p) abort(); return p; } static inline void *xrealloc(void *p, size_t n) { +#ifdef UNIT_TESTING + p = test_realloc(p, n); +#else p = realloc(p, n); +#endif if(!p) abort(); return p;