From: Lennart Poettering Date: Sat, 10 Apr 2010 15:47:07 +0000 (+0200) Subject: execute: introduce exec_command_done() to free data from static ExecCommand structs X-Git-Tag: 0.git+20100605+dfd8ee-1~164 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43d0fcbd3f54a5f3c5636acf9b54f19a07de7a18;p=systemd execute: introduce exec_command_done() to free data from static ExecCommand structs --- diff --git a/execute.c b/execute.c index 6cf6615d..3d2e5113 100644 --- a/execute.c +++ b/execute.c @@ -776,14 +776,29 @@ void exec_context_done(ExecContext *c) { } } +void exec_command_done(ExecCommand *c) { + assert(c); + + free(c->path); + c->path = NULL; + + strv_free(c->argv); + c->argv = NULL; +} + +void exec_command_done_array(ExecCommand *c, unsigned n) { + unsigned i; + + for (i = 0; i < n; i++) + exec_command_done(c+i); +} + void exec_command_free_list(ExecCommand *c) { ExecCommand *i; while ((i = c)) { LIST_REMOVE(ExecCommand, command, c, i); - - free(i->path); - strv_free(i->argv); + exec_command_done(i); free(i); } } diff --git a/execute.h b/execute.h index 18948173..b4bb9600 100644 --- a/execute.h +++ b/execute.h @@ -162,6 +162,9 @@ int exec_spawn(ExecCommand *command, struct CGroupBonding *cgroup_bondings, pid_t *ret); +void exec_command_done(ExecCommand *c); +void exec_command_done_array(ExecCommand *c, unsigned n); + void exec_command_free_list(ExecCommand *c); void exec_command_free_array(ExecCommand **c, unsigned n);