From d26c0d87f67df84a1824a25dfba0cf6b02c33b95 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 7 Mar 2013 15:41:34 -0500 Subject: [PATCH] Convert efree() to a macro that just casts to void * and does free(). If the system free() can't handle free(NULL) this may crash but C89 was a long time ago. --- common/alloc.c | 10 ---------- include/alloc.h | 4 +++- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/common/alloc.c b/common/alloc.c index 09c95f5eb..e69c367bd 100644 --- a/common/alloc.c +++ b/common/alloc.c @@ -271,13 +271,3 @@ evasprintf(char **ret, const char *format, va_list args) errorx_nodebug(1, NULL); return len; } - -/* - * Wrapper for free(3) so we can depend on C89 semantics. - */ -void -efree(void *ptr) -{ - if (ptr != NULL) - free(ptr); -} diff --git a/include/alloc.h b/include/alloc.h index 77ba2a289..4bf4e7b10 100644 --- a/include/alloc.h +++ b/include/alloc.h @@ -19,9 +19,11 @@ #include +#undef efree +#define efree(x) free((void *)(x)) + int easprintf(char **, const char *, ...) __printflike(2, 3); int evasprintf(char **, const char *, va_list) __printflike(2, 0); -void efree(void *); void *ecalloc(size_t, size_t) __malloc_like; void *emalloc(size_t) __malloc_like; void *emalloc2(size_t, size_t) __malloc_like;