summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2023-05-16 08:19:09 +0200
committerFrantisek Sumsal <frantisek@sumsal.cz>2023-05-16 11:27:10 +0200
commit53ac7f1d54b925f7aeda47a9f26ac4a1bc0b3987 (patch)
tree6e589f0927bb86de81a413b2c2bc9601e68c278d
parent825210d4e5d52655ff893d600da2d2c8e5c0c8e1 (diff)
downloadsystemd-53ac7f1d54b925f7aeda47a9f26ac4a1bc0b3987.tar.gz
nspawn: modernize the cleanup functions a bit
-rw-r--r--src/nspawn/nspawn-settings.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/nspawn/nspawn-settings.c b/src/nspawn/nspawn-settings.c
index 94a4c80ed6..161b1c1c70 100644
--- a/src/nspawn/nspawn-settings.c
+++ b/src/nspawn/nspawn-settings.c
@@ -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) {