From ad73653d36c9bd59872479e3c41f8942c70945b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 9 Nov 2024 12:40:59 +0100 Subject: Adding upstream version 4.3+20241108. Signed-off-by: Daniel Baumann --- dlink.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'dlink.c') diff --git a/dlink.c b/dlink.c index 69aa7aa..3463367 100644 --- a/dlink.c +++ b/dlink.c @@ -26,6 +26,21 @@ void dl_free(void *v) free(vv-1); } +void dl_free_all(void *head) +{ + /* The list head is linked with the list tail so in order to free + * all the elements properly there is a need to keep starting point. + */ + void *d = dl_next(head), *next; + + while (d != head) { + next = dl_next(d); + dl_free(d); + d = next; + } + dl_free(head); +} + void dl_init(void *v) { dl_next(v) = v; -- cgit v1.2.3