1 #ifndef __XMALLOC_H 2 #define __XMALLOC_H 3 4 #if __STDC__ 5 # define VOID void 6 #else 7 # define VOID char 8 #endif 9 10 extern VOID *xmalloc (size_t n); 11 extern VOID *xcalloc (size_t n, size_t s); 12 extern VOID *xrealloc (VOID *p, size_t n); 13 extern char *xstrdup (char *str); 14 15 #define XCALLOC(type, num) \ 16 ((type *) xcalloc ((num), sizeof(type))) 17 #define XMALLOC(type, num) \ 18 ((type *) xmalloc ((num) * sizeof(type))) 19 #define XREALLOC(type, p, num) \ 20 ((type *) xrealloc ((p), (num) * sizeof(type))) 21 #define XFREE(stale) do { \ 22 if (stale) { free (stale); stale = 0; } \ 23 } while (0) 24 25 #endif /* __XMALLOC_H */ 26