From 41ae0f267f97372b7eaef62d6886a14db0569424 Mon Sep 17 00:00:00 2001 From: Masanori Kakura Date: Thu, 1 Oct 2020 21:59:59 +0900 Subject: [PATCH] [eglib] Implement g_slist_free_full(). --- src/glib.h | 2 ++ src/gslist.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/glib.h b/src/glib.h index 4b2c6d6..4905fc8 100644 --- a/src/glib.h +++ b/src/glib.h @@ -332,6 +332,8 @@ GSList *g_slist_prepend (GSList *list, gpointer data); void g_slist_free (GSList *list); void g_slist_free_1 (GSList *list); +void g_slist_free_full (GSList *list, + GDestroyNotify free_func); GSList *g_slist_copy (GSList *list); GSList *g_slist_concat (GSList *list1, GSList *list2); diff --git a/src/gslist.c b/src/gslist.c index 5baa297..de3e203 100644 --- a/src/gslist.c +++ b/src/gslist.c @@ -124,6 +124,17 @@ g_slist_free (GSList *list) } } +void +g_slist_free_full (GSList *list, GDestroyNotify free_func) +{ + while (list) { + GSList *next = list->next; + (*free_func) (list->data); + g_slist_free_1 (list); + list = next; + } +} + GSList* g_slist_copy (GSList *list) {