Add fw3_free_list() helper
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 26 May 2013 13:58:17 +0000 (15:58 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 26 May 2013 14:09:01 +0000 (16:09 +0200)
utils.c
utils.h

diff --git a/utils.c b/utils.c
index ea409742f829bd720dd043eff822a11235506c91..99310f731337879ee730f5a48a9c2c75522efdb4 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -656,6 +656,22 @@ fw3_free_object(void *obj, const void *opts)
        free(obj);
 }
 
+void
+fw3_free_list(struct list_head *head)
+{
+       struct list_head *entry, *tmp;
+
+       if (!head)
+               return;
+
+       list_for_each_safe(entry, tmp, head)
+       {
+               list_del(entry);
+               free(entry);
+       }
+
+       free(head);
+}
 
 bool
 fw3_hotplug(bool add, void *zone, void *device)
diff --git a/utils.h b/utils.h
index 0d1b9d836a56b6f194d3cbd0ed8f72fb8ddb6e06..cd478f9d80886855ecf88e3df3319130c50233f0 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -91,6 +91,8 @@ void fw3_write_statefile(void *state);
 
 void fw3_free_object(void *obj, const void *opts);
 
+void fw3_free_list(struct list_head *head);
+
 bool fw3_hotplug(bool add, void *zone, void *device);
 
 #endif