diff options
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/common.h b/common.h new file mode 100644 index 0000000..10fa22b --- /dev/null +++ b/common.h @@ -0,0 +1,10 @@ +#define psizeof(a) (sizeof(a) / sizeof(*(a))) + +static inline void *memdup(void *src, size_t size) { + void *r = malloc(size); + memcpy(r, src, size); + return r; +} +static inline void ifree(void *p) { + if (p) { free(p); p = NULL; } +} |