From b59c49627595da73b4f6ea8a88829d97f4f76c84 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 26 May 2013 15:58:17 +0200 Subject: [PATCH] Add fw3_free_list() helper --- utils.c | 16 ++++++++++++++++ utils.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/utils.c b/utils.c index ea40974..99310f7 100644 --- 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 0d1b9d8..cd478f9 100644 --- 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 -- 2.30.2