}
char *unit_name_path_escape(const char *f) {
- char *p, *e;
+ _cleanup_free_ char *p;
assert(f);
path_kill_slashes(p);
- if (streq(p, "/") || streq(p, "")) {
- free(p);
+ if (streq(p, "/") || streq(p, ""))
return strdup("-");
- }
-
- e = unit_name_escape(p[0] == '/' ? p + 1 : p);
- free(p);
- return e;
+ return unit_name_escape(p[0] == '/' ? p + 1 : p);
}
char *unit_name_path_unescape(const char *f) {
}
char *unit_name_from_path(const char *path, const char *suffix) {
- char *p, *r;
+ _cleanup_free_ char *p = NULL;
assert(path);
assert(suffix);
if (!p)
return NULL;
- r = strappend(p, suffix);
- free(p);
-
- return r;
+ return strappend(p, suffix);
}
char *unit_name_from_path_instance(const char *prefix, const char *path, const char *suffix) {
- char *p, *r;
+ _cleanup_free_ char *p = NULL;
assert(prefix);
assert(path);
if (!p)
return NULL;
- r = strjoin(prefix, "@", p, suffix, NULL);
- free(p);
-
- return r;
+ return strjoin(prefix, "@", p, suffix, NULL);
}
char *unit_name_to_path(const char *name) {