add node destruction in cxLinkedListDestroy()

Mon, 27 Sep 2021 17:00:19 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 27 Sep 2021 17:00:19 +0200
changeset 436
ca9ce2297c29
parent 435
0fe204d50f54
child 437
9d4971ea0625

add node destruction in cxLinkedListDestroy()

src/linked_list.c file | annotate | diff | comparison | revisions
--- a/src/linked_list.c	Sun Sep 26 18:31:24 2021 +0200
+++ b/src/linked_list.c	Mon Sep 27 17:00:19 2021 +0200
@@ -177,7 +177,15 @@
 }
 
 void cxLinkedListDestroy(CxList list) {
-    // TODO: free contents
+    cx_linked_list* ll = (cx_linked_list*) list;
+
+    struct cx_linked_list_node* node = ll->begin;
+    while (node) {
+        void* next = node->next;
+        cxFree(list->allocator, node);
+        node = next;
+    }
+
     cxFree(list->allocator, list);
 }
 

mercurial