summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-03-04 09:20:51 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-03-04 10:04:50 -0500
commit6e18964d3a365567954fe10ddcfad74babdc427c (patch)
treea1e62c233e0cac0224623049e6fb98b8e450d0ac /src/core
parente062dec5ae1a443d47885537af85d328c83c67db (diff)
Introduce strv_consume which takes ownership
This mirrors set_consume and makes the common use a bit nicer.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/dbus-execute.c8
-rw-r--r--src/core/locale-setup.c3
-rw-r--r--src/core/unit.c6
3 files changed, 6 insertions, 11 deletions
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 6d0bdce9dc..3a05303f08 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -385,11 +385,9 @@ static int property_get_syscall_filter(
if (!name)
continue;
- r = strv_push(&l, name);
- if (r < 0) {
- free(name);
- return -ENOMEM;
- }
+ r = strv_consume(&l, name);
+ if (r < 0)
+ return r;
}
#endif
diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c
index 276deb9dc1..7a4103504f 100644
--- a/src/core/locale-setup.c
+++ b/src/core/locale-setup.c
@@ -133,8 +133,7 @@ int locale_setup(char ***environment) {
goto finish;
}
- if (strv_push(&add, s) < 0) {
- free(s);
+ if (strv_consume(&add, s) < 0) {
r = -ENOMEM;
goto finish;
}
diff --git a/src/core/unit.c b/src/core/unit.c
index 1c0b0c72ac..d0e915909a 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -3181,11 +3181,9 @@ int unit_require_mounts_for(Unit *u, const char *path) {
return 0;
}
- r = strv_push(&u->requires_mounts_for, p);
- if (r < 0) {
- free(p);
+ r = strv_consume(&u->requires_mounts_for, p);
+ if (r < 0)
return r;
- }
PATH_FOREACH_PREFIX_MORE(prefix, p) {
Set *x;