summaryrefslogtreecommitdiff
path: root/src/core/main.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-23 01:01:26 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-29 21:08:37 +0200
commitfe382237cad0ade50d38075e0bf948ce07618461 (patch)
tree3a9b109b322c317276dccb1cb89446ddde7e6b32 /src/core/main.c
parent3ee897d6c2401effbc82f5eef35fce405781d6c8 (diff)
strv: add strv_free_free() to strv.c and make use of it
Let's teach it a new trick, and make it return NULL.
Diffstat (limited to 'src/core/main.c')
-rw-r--r--src/core/main.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/src/core/main.c b/src/core/main.c
index bc72a2b00b..3fc6efa291 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -478,23 +478,6 @@ static int config_parse_show_status(
return 0;
}
-static void strv_free_free(char ***l) {
- char ***i;
-
- if (!l)
- return;
-
- for (i = l; *i; i++)
- strv_free(*i);
-
- free(l);
-}
-
-static void free_join_controllers(void) {
- strv_free_free(arg_join_controllers);
- arg_join_controllers = NULL;
-}
-
static int config_parse_join_controllers(const char *unit,
const char *filename,
unsigned line,
@@ -513,7 +496,7 @@ static int config_parse_join_controllers(const char *unit,
assert(lvalue);
assert(rvalue);
- free_join_controllers();
+ arg_join_controllers = strv_free_free(arg_join_controllers);
for (;;) {
_cleanup_free_ char *word = NULL;
@@ -1116,15 +1099,19 @@ static int initialize_join_controllers(void) {
return -ENOMEM;
arg_join_controllers[0] = strv_new("cpu", "cpuacct", NULL);
- arg_join_controllers[1] = strv_new("net_cls", "net_prio", NULL);
- arg_join_controllers[2] = NULL;
+ if (!arg_join_controllers[0])
+ goto oom;
- if (!arg_join_controllers[0] || !arg_join_controllers[1]) {
- free_join_controllers();
- return -ENOMEM;
- }
+ arg_join_controllers[1] = strv_new("net_cls", "net_prio", NULL);
+ if (!arg_join_controllers[1])
+ goto oom;
+ arg_join_controllers[2] = NULL;
return 0;
+
+oom:
+ arg_join_controllers = strv_free_free(arg_join_controllers);
+ return -ENOMEM;
}
static int enforce_syscall_archs(Set *archs) {
@@ -1813,17 +1800,15 @@ finish:
arg_shutdown_watchdog = m->shutdown_watchdog;
shutdown_exit_code = m->return_value;
}
+
m = manager_free(m);
for (j = 0; j < ELEMENTSOF(arg_default_rlimit); j++)
arg_default_rlimit[j] = mfree(arg_default_rlimit[j]);
arg_default_unit = mfree(arg_default_unit);
-
- free_join_controllers();
-
+ arg_join_controllers = strv_free_free(arg_join_controllers);
arg_default_environment = strv_free(arg_default_environment);
-
arg_syscall_archs = set_free(arg_syscall_archs);
mac_selinux_finish();