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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user