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
     1.1 --- a/src/linked_list.c	Sun Sep 26 18:31:24 2021 +0200
     1.2 +++ b/src/linked_list.c	Mon Sep 27 17:00:19 2021 +0200
     1.3 @@ -177,7 +177,15 @@
     1.4  }
     1.5  
     1.6  void cxLinkedListDestroy(CxList list) {
     1.7 -    // TODO: free contents
     1.8 +    cx_linked_list* ll = (cx_linked_list*) list;
     1.9 +
    1.10 +    struct cx_linked_list_node* node = ll->begin;
    1.11 +    while (node) {
    1.12 +        void* next = node->next;
    1.13 +        cxFree(list->allocator, node);
    1.14 +        node = next;
    1.15 +    }
    1.16 +
    1.17      cxFree(list->allocator, list);
    1.18  }
    1.19  

mercurial