From 4fdec49be6aa9456e62b1ba8d2cbace08e52b9e7 Mon Sep 17 00:00:00 2001 From: Bruce Cowan <bruce@bcowan.me.uk> Date: Wed, 14 Feb 2024 19:15:42 +0000 Subject: [PATCH] slist: Fix free_all function --- lib/types/slist.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/types/slist.c b/lib/types/slist.c index 1af596c..6a718dd 100644 --- a/lib/types/slist.c +++ b/lib/types/slist.c @@ -102,5 +102,14 @@ void slist_free_all (SList *list, FreeFunc func) { - slist_foreach (list, (ForEachFunc) slist_free_one, NULL); + SList *next; + + if (!list) + return; + + for (SList *l = list; l; l = next) + { + next = l->next; + slist_free_one (l, func); + } } -- GitLab