]> granicus.if.org Git - sudo/commitdiff
Convert efree() to a macro that just casts to void * and does free().
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 7 Mar 2013 20:41:34 +0000 (15:41 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 7 Mar 2013 20:41:34 +0000 (15:41 -0500)
If the system free() can't handle free(NULL) this may crash but C89
was a long time ago.

common/alloc.c
include/alloc.h

index 09c95f5ebae96b36b3708632a89a0e810ce31cee..e69c367bde8d9380979dc1e8a1ebb5d2193142f5 100644 (file)
@@ -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);
-}
index 77ba2a28913ae19014c897b9d47c27dd1eb668ca..4bf4e7b10241312f82502a9c74dc0254f336b08f 100644 (file)
 
 #include <stdarg.h>
 
+#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;