make: fix build error in curvetun due to empty env var
[netsniff-ng.git] / src / xmalloc.h
blob92eced93275026ec42eaed6916ca2a0672f2ccca
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2009, 2010 Daniel Borkmann.
5 * Subject to the GPL, version 2.
6 */
8 #ifndef XMALLOC_H
9 #define XMALLOC_H
11 #include <stdlib.h>
13 #include "built_in.h"
14 #include "die.h"
16 extern __hidden void *xmalloc(size_t size);
17 extern __hidden void *xzmalloc(size_t size);
18 extern __hidden void *xmallocz(size_t size);
19 extern __hidden void *xmalloc_aligned(size_t size, size_t alignment);
20 extern __hidden void *xzmalloc_aligned(size_t size, size_t alignment);
21 extern __hidden void *xmemdupz(const void *data, size_t len);
22 extern __hidden void *xrealloc(void *ptr, size_t nmemb, size_t size);
23 extern __hidden void xfree_func(void *ptr);
24 extern __hidden char *xstrdup(const char *str);
25 extern __hidden char *xstrndup(const char *str, size_t size);
26 extern __hidden int xdup(int fd);
28 #define xfree(ptr) \
29 do { \
30 if (unlikely((ptr) == NULL)) \
31 panic("xfree: NULL pointer given as argument\n"); \
32 free((ptr)); \
33 (ptr) = NULL; \
34 } while (0)
36 #endif /* XMALLOC_H */