From: Lennart Poettering Date: Wed, 21 Nov 2018 15:43:40 +0000 (+0100) Subject: unit: minor optimization, use stack over heap, when we can X-Git-Tag: v240~241 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=00e7b3c8e509a51517e7dd13cf24f9abba29f780;p=thirdparty%2Fsystemd.git unit: minor optimization, use stack over heap, when we can --- diff --git a/src/core/unit.c b/src/core/unit.c index 359bd62df9a..f6c2e08b55a 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2985,7 +2985,6 @@ int unit_set_slice(Unit *u, Unit *slice) { } int unit_set_default_slice(Unit *u) { - _cleanup_free_ char *b = NULL; const char *slice_name; Unit *slice; int r; @@ -3013,13 +3012,9 @@ int unit_set_default_slice(Unit *u) { return -ENOMEM; if (MANAGER_IS_SYSTEM(u->manager)) - b = strjoin("system-", escaped, ".slice"); + slice_name = strjoina("system-", escaped, ".slice"); else - b = strappend(escaped, ".slice"); - if (!b) - return -ENOMEM; - - slice_name = b; + slice_name = strjoina(escaped, ".slice"); } else slice_name = MANAGER_IS_SYSTEM(u->manager) && !unit_has_name(u, SPECIAL_INIT_SCOPE)