diff --git a/src/libckpool.c b/src/libckpool.c index f2937a05..bed7a816 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -1295,12 +1295,6 @@ void *_ckzalloc(size_t len, const char *file, const char *func, const int line) return ptr; } -void _dealloc(void **ptr) -{ - free(*ptr); - *ptr = NULL; -} - /* Adequate size s==len*2 + 1 must be alloced to use this variant */ void __bin2hex(void *vs, const void *vp, size_t len) { diff --git a/src/libckpool.h b/src/libckpool.h index 1b24d9c2..cb7c1d01 100644 --- a/src/libckpool.h +++ b/src/libckpool.h @@ -177,7 +177,10 @@ static inline void flip_80(void *dest_p, const void *src_p) #define ckalloc(len) _ckalloc(len, __FILE__, __func__, __LINE__) #define ckzalloc(len) _ckzalloc(len, __FILE__, __func__, __LINE__) -#define dealloc(ptr) _dealloc((void *)&(ptr)) +#define dealloc(ptr) do { \ + free(ptr); \ + ptr = NULL; \ +} while (0) #define VASPRINTF(strp, fmt, ...) do { \ if (unlikely(vasprintf(strp, fmt, ##__VA_ARGS__) < 0)) \ @@ -499,7 +502,6 @@ void trail_slash(char **buf); void *_ckalloc(size_t len, const char *file, const char *func, const int line); void *json_ckalloc(size_t size); void *_ckzalloc(size_t len, const char *file, const char *func, const int line); -void _dealloc(void **ptr); extern const int hex2bin_tbl[]; void __bin2hex(void *vs, const void *vp, size_t len); void *bin2hex(const void *vp, size_t len);