tree-wide: introduce mfree()

Pretty trivial helper which wraps free() but returns NULL, so we can
simplify this:
        free(foobar);
        foobar = NULL;
to this:
        foobar = mfree(foobar);
This commit is contained in:
David Herrmann
2015-07-31 19:56:38 +02:00
parent b2a0ac5e5b
commit 97b11eedff
25 changed files with 64 additions and 119 deletions
+2 -4
View File
@@ -467,8 +467,7 @@ int copy_xattr(int fdf, int fdt) {
sza *= 2;
free(bufa);
bufa = NULL;
bufa = mfree(bufa);
}
p = bufa;
@@ -491,8 +490,7 @@ int copy_xattr(int fdf, int fdt) {
if (m < 0) {
if (errno == ERANGE) {
szb *= 2;
free(bufb);
bufb = NULL;
bufb = mfree(bufb);
continue;
}
+5
View File
@@ -84,6 +84,11 @@ bool streq_ptr(const char *a, const char *b) _pure_;
#define malloc0(n) (calloc((n), 1))
static inline void *mfree(void *memory) {
free(memory);
return NULL;
}
static inline const char* yes_no(bool b) {
return b ? "yes" : "no";
}