A re-cap of the memory management macros discussed in the previous sections, without any of the debugging versions is shown below:
#ifndef H_xmemory
#define H_xmemory
#include <stdlib.h>
#include <string.h>
#define xalloc(_t) ((_t*)malloc(sizeof(_t)))
#define xnalloc(_t,_n) ((_t*)malloc(sizeof(_t)*(_n)))
#define xalloc0(_t) ((_t*)calloc(sizeof(_t), 1))
#define xnalloc0(_t,_n) ((_t*)calloc(sizeof(_t),(_n)))
#define xvalloc(_t1,_t2,_n) ((_t1*)malloc(sizeof(_t1)+((_n)-1)*sizeof(t2)))
#define xfree(_t,_p) free(_p)
#define xnfree(_t,_n,_p) free(_p)
#define xvfree(_t1,_t2,_n,_p) free(_p)
#if( SUPPORTS_ALLOCA )
#define xalloc_stack(_t) ((_t*)alloca(sizeof(_t)))
#define xnalloc_stack(_t,_n) ((_t*)alloca(sizeof(_t)*(_n)))
#define xalloc0_stack(_t) \
((_t*)memset( (void*)alloca(sizeof(_t)) ,0,sizeof(_t)))
#define xnalloc0_stack(_t,_n) \
((_t*)memset( (void*)alloca(sizeof(_t)*(_n)) ,0,sizeof(_t)*(_n)))
#define xfree_stack(_t,_p) ((void)0)
#define xnfree_stack(_t,_n,_p) ((void)0)
#else
#define xalloc_stack(_t) xalloc(_t)
#define xnalloc_stack(_t,_n) xnalloc(_t,_n)
#define xalloc0_stack(_t) xalloc0(_t)
#define xnalloc0_stack(_t,_n) xnalloc0(_t,_n)
#define xfree_stack(_t,_p) xfree(_t,_p)
#define xnfree_stack(_t,_n,_p) xnfree(_t,_n,_p)
#endif
#endif