tree-wide: use free_and_strdup()

Use free_and_strdup() where appropriate and replace equivalent,
open-coded versions.
This commit is contained in:
Daniel Mack
2015-07-30 13:09:01 +02:00
parent 5f17089ac1
commit 2fc09a9cdd
10 changed files with 40 additions and 59 deletions
+4 -5
View File
@@ -673,6 +673,7 @@ int unit_name_mangle_with_suffix(const char *name, UnitNameMangle allow_globs, c
int slice_build_parent_slice(const char *slice, char **ret) {
char *s, *dash;
int r;
assert(slice);
assert(ret);
@@ -693,11 +694,9 @@ int slice_build_parent_slice(const char *slice, char **ret) {
if (dash)
strcpy(dash, ".slice");
else {
free(s);
s = strdup("-.slice");
if (!s)
return -ENOMEM;
r = free_and_strdup(&s, "-.slice");
if (r < 0)
return r;
}
*ret = s;