Revert "flowtop: Don't init screen until collector is ready"
[netsniff-ng-new.git] / xmalloc.h
blob7228bde51d75ac1de64919547c2f986b06686c87
1 #ifndef XMALLOC_H
2 #define XMALLOC_H
4 #include <stdlib.h>
6 #include "built_in.h"
7 #include "die.h"
9 extern void *xmalloc(size_t size) __hidden __warn_unused_result;
10 extern void *xcalloc(size_t nmemb, size_t size) __hidden __warn_unused_result;
11 extern void *xzmalloc(size_t size) __hidden __warn_unused_result;
12 extern void *xmallocz(size_t size) __hidden __warn_unused_result;
13 extern void *xmalloc_aligned(size_t size, size_t alignment) __hidden __warn_unused_result;
14 extern void *xzmalloc_aligned(size_t size, size_t alignment) __hidden __warn_unused_result;
15 extern void *xmemdupz(const void *data, size_t len) __hidden __warn_unused_result;
16 extern void *xrealloc(void *ptr, size_t size) __hidden __warn_unused_result;
17 extern void xfree_func(void *ptr) __hidden;
18 extern char *xstrdup(const char *str) __hidden __warn_unused_result;
19 extern char *xstrndup(const char *str, size_t size) __hidden __warn_unused_result;
21 static inline void __xfree(void *ptr)
23 if (unlikely((ptr) == NULL))
24 panic("xfree: NULL pointer given as argument\n");
25 free(ptr);
28 #define xzfree(ptr, size) \
29 do { \
30 xmemset(ptr, 0, size); \
31 xfree(ptr); \
32 } while (0)
34 #define xfree(ptr) \
35 do { \
36 __xfree(ptr); \
37 (ptr) = NULL; \
38 } while (0)
40 #endif /* XMALLOC_H */