summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-10-25 00:29:05 +0200
committerLennart Poettering <lennart@poettering.net>2016-11-02 11:29:59 -0600
commita581e45ae8f9bb5c6693c23c78bc070aa15d0c8a (patch)
treec881c7d827d8789d4cbdebfd8df678731afc8e6e /src/core/unit.c
parent11222d0fe0b5abb0cef65359b979e0c7f50129f3 (diff)
unit: unify some code with new unit_new_for_name() call
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index 8d74b44f73..068d319206 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -109,6 +109,24 @@ Unit *unit_new(Manager *m, size_t size) {
return u;
}
+int unit_new_for_name(Manager *m, size_t size, const char *name, Unit **ret) {
+ Unit *u;
+ int r;
+
+ u = unit_new(m, size);
+ if (!u)
+ return -ENOMEM;
+
+ r = unit_add_name(u, name);
+ if (r < 0) {
+ unit_free(u);
+ return r;
+ }
+
+ *ret = u;
+ return r;
+}
+
bool unit_has_name(Unit *u, const char *name) {
assert(u);
assert(name);