xmalloc.h 578 Bytes
Newer Older
Alastair McKinstry's avatar
Alastair McKinstry committed
1
/* Error-free versions of some libc routines */
Alastair McKinstry's avatar
Alastair McKinstry committed
2 3


Alastair McKinstry's avatar
Alastair McKinstry committed
4
#include <stdlib.h>
5

Alastair McKinstry's avatar
Alastair McKinstry committed
6 7 8 9 10
#if defined(NDEBUG)

#define xmalloc(sz)      malloc(sz)
#define xrealloc(p,sz)   realloc(p,sz)
#define xstrdup(p)       strdup(p)
11 12 13
#define lkfatal(S)      do {} while(0)
#define lkfatal1(S1,S2) do {} while(0)
#define lkfatal0(S1,X)  do {} while(0)
Alastair McKinstry's avatar
Alastair McKinstry committed
14 15 16

#else

Alastair McKinstry's avatar
Alastair McKinstry committed
17 18
extern void *xmalloc(size_t sz);
extern void *xrealloc(void *p, size_t sz);
19
extern char *xstrdup(const char *p);
20 21 22
extern void lkfatal(const char *s);
extern void lkfatal1(const char *s, const char *s2);
extern void lkfatal0(const char *, int);
Alastair McKinstry's avatar
Alastair McKinstry committed
23 24

#endif