tree-wide: introduce free_and_replace helper

It's a common pattern, so add a helper for it. A macro is necessary
because a function that takes a pointer to a pointer would be type specific,
similarly to cleanup functions. Seems better to use a macro.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2016-10-16 23:35:39 -04:00
parent 6b430fdb7c
commit 3b319885c4
9 changed files with 35 additions and 42 deletions
+1 -3
View File
@@ -288,9 +288,7 @@ char **path_strv_resolve(char **l, const char *prefix) {
} else {
/* canonicalized path goes outside of
* prefix, keep the original path instead */
free(u);
u = orig;
orig = NULL;
free_and_replace(u, orig);
}
} else
free(t);