diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2013-05-12 13:29:14 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2013-05-12 13:29:14 +0200 |
commit | 06d60f51149ef960110431b228828c7bbc84e74c (patch) | |
tree | 7cebcc8f29513c62a50de730f80784bcd97f8dfb | |
parent | e12a08652f7d2b92e75d8dd7b8528d1d0e69b2a8 (diff) |
xmalloc: Make xfree a two part macro/inline
This way the coverity scanner will no longer complain about dereference
before NULL checks right before xfree().
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r-- | xmalloc.h | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -24,12 +24,17 @@ extern char *xstrdup(const char *str) __hidden; extern char *xstrndup(const char *str, size_t size) __hidden; extern int xdup(int fd) __hidden; -#define xfree(ptr) \ -do { \ - if (unlikely((ptr) == NULL)) \ - panic("xfree: NULL pointer given as argument\n"); \ - free((ptr)); \ - (ptr) = NULL; \ +static inline void __xfree(void *ptr) +{ + if (unlikely((ptr) == NULL)) + panic("xfree: NULL pointer given as argument\n"); + free(ptr); +} + +#define xfree(ptr) \ +do { \ + __xfree(ptr); \ + (ptr) = NULL; \ } while (0) #endif /* XMALLOC_H */ |