src/linked_list.c

changeset 708
1caed6c9ba68
parent 703
425d4279856f
child 735
b686d0c98c62
equal deleted inserted replaced
707:87eb4bdb2d0e 708:1caed6c9ba68
874 static void cx_ll_destructor(CxList *list) { 874 static void cx_ll_destructor(CxList *list) {
875 cx_linked_list *ll = (cx_linked_list *) list; 875 cx_linked_list *ll = (cx_linked_list *) list;
876 876
877 cx_linked_list_node *node = ll->begin; 877 cx_linked_list_node *node = ll->begin;
878 while (node) { 878 while (node) {
879 cx_invoke_destructor(list, node->payload);
879 void *next = node->next; 880 void *next = node->next;
880 cxFree(list->allocator, node); 881 cxFree(list->allocator, node);
881 node = next; 882 node = next;
882 } 883 }
883 // do not free the list pointer, this is just a destructor! 884
885 cxFree(list->allocator, list);
884 } 886 }
885 887
886 static cx_list_class cx_linked_list_class = { 888 static cx_list_class cx_linked_list_class = {
887 cx_ll_destructor, 889 cx_ll_destructor,
888 cx_ll_insert_element, 890 cx_ll_insert_element,

mercurial