chiark / gitweb /
execute: introduce exec_command_done() to free data from static ExecCommand structs
authorLennart Poettering <lennart@poettering.net>
Sat, 10 Apr 2010 15:47:07 +0000 (17:47 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 10 Apr 2010 16:00:34 +0000 (18:00 +0200)
execute.c
execute.h

index 6cf6615da4befc39eca0e9563766e1556cc183ef..3d2e511333b9d6003114c94afe2e5daa8cc75736 100644 (file)
--- 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);
         }
 }
index 18948173b86f8b5e542733cbec2c6014429aba39..b4bb9600d1e691e8c697f2b2ed39e2dc98a308c6 100644 (file)
--- 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);