diff options
Diffstat (limited to 'src/basic/path-lookup.c')
-rw-r--r-- | src/basic/path-lookup.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/basic/path-lookup.c b/src/basic/path-lookup.c index e7fc4a7f06..540256b73b 100644 --- a/src/basic/path-lookup.c +++ b/src/basic/path-lookup.c @@ -92,7 +92,6 @@ int xdg_user_data_dir(char **ret, const char *suffix) { } int runtime_directory(char **ret, RuntimeScope scope, const char *suffix) { - _cleanup_free_ char *d = NULL; int r; assert(ret); @@ -106,26 +105,20 @@ int runtime_directory(char **ret, RuntimeScope scope, const char *suffix) { * Return value indicates whether the suffix was applied or not */ const char *e = secure_getenv("RUNTIME_DIRECTORY"); - if (e) { - d = strdup(e); - if (!d) - return -ENOMEM; - - *ret = TAKE_PTR(d); - return false; - } + if (e) + return strdup_to(ret, e); if (scope == RUNTIME_SCOPE_USER) { - r = xdg_user_runtime_dir(&d, suffix); + r = xdg_user_runtime_dir(ret, suffix); if (r < 0) return r; } else { - d = path_join("/run", suffix); + char *d = path_join("/run", suffix); if (!d) return -ENOMEM; + *ret = d; } - *ret = TAKE_PTR(d); return true; } |