]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: modernize the cleanup functions a bit
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 16 May 2023 06:19:09 +0000 (08:19 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 16 May 2023 09:27:10 +0000 (11:27 +0200)
src/nspawn/nspawn-settings.c

index 94a4c80ed6cec6a6a319e420d513fe919934f5ed..161b1c1c7047f38d961213ced63b4d7a81560803 100644 (file)
@@ -97,29 +97,25 @@ int settings_load(FILE *f, const char *path, Settings **ret) {
         return 0;
 }
 
-static void free_oci_hooks(OciHook *h, size_t n) {
-        size_t i;
+static void free_oci_hooks(OciHook *hooks, size_t n) {
+        assert(hooks || n == 0);
 
-        assert(h || n == 0);
-
-        for (i = 0; i < n; i++) {
-                free(h[i].path);
-                strv_free(h[i].args);
-                strv_free(h[i].env);
+        FOREACH_ARRAY(hook, hooks, n) {
+                free(hook->path);
+                strv_free(hook->args);
+                strv_free(hook->env);
         }
 
-        free(h);
+        free(hooks);
 }
 
-void device_node_array_free(DeviceNode *node, size_t n) {
-        size_t i;
-
-        assert(node || n == 0);
+void device_node_array_free(DeviceNode *nodes, size_t n) {
+        assert(nodes || n == 0);
 
-        for (i = 0; i < n; i++)
-                free(node[i].path);
+        FOREACH_ARRAY(node, nodes, n)
+                free(node->path);
 
-        free(node);
+        free(nodes);
 }
 
 Settings* settings_free(Settings *s) {