Added support for cmocka *alloc
This commit is contained in:
parent
dca3558d05
commit
536256b2da
1 changed files with 12 additions and 0 deletions
12
src/xalloc.h
12
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;
|
||||
|
|
Loading…
Reference in a new issue