docs: update credits for former maintainership
[netsniff-ng.git] / xmalloc.h
blob952b8276320f1819fbe41a007205b77348fd47d4
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;
10 extern void *xzmalloc(size_t size) __hidden;
11 extern void *xmallocz(size_t size) __hidden;
12 extern void *xmalloc_aligned(size_t size, size_t alignment) __hidden;
13 extern void *xzmalloc_aligned(size_t size, size_t alignment) __hidden;
14 extern void *xmemdupz(const void *data, size_t len) __hidden;
15 extern void *xrealloc(void *ptr, size_t nmemb, size_t size) __hidden;
16 extern void xfree_func(void *ptr) __hidden;
17 extern char *xstrdup(const char *str) __hidden;
18 extern char *xstrndup(const char *str, size_t size) __hidden;
20 static inline void __xfree(void *ptr)
22 if (unlikely((ptr) == NULL))
23 panic("xfree: NULL pointer given as argument\n");
24 free(ptr);
27 #define xzfree(ptr, size) \
28 do { \
29 xmemset(ptr, 0, size); \
30 xfree(ptr); \
31 } while (0)
33 #define xfree(ptr) \
34 do { \
35 __xfree(ptr); \
36 (ptr) = NULL; \
37 } while (0)
39 #endif /* XMALLOC_H */