1.1 --- a/src/list.c Mon Apr 18 16:56:29 2022 +0200 1.2 +++ b/src/list.c Mon Apr 18 17:26:21 2022 +0200 1.3 @@ -28,14 +28,26 @@ 1.4 1.5 #include "cx/list.h" 1.6 1.7 -CxList *cxListDestroy(CxList *list) { 1.8 - if (list->content_destructor != NULL) { 1.9 - CxIterator iter = cxListBegin(list); 1.10 - cx_foreach(void*, elem, iter) { 1.11 - list->content_destructor(elem); 1.12 +void cxListDestroy(CxList *list) { 1.13 + switch (list->content_destructor_type) { 1.14 + case CX_DESTRUCTOR_SIMPLE: { 1.15 + CxIterator iter = cxListBegin(list); 1.16 + cx_foreach(void*, elem, iter) { 1.17 + list->simple_destructor(elem); 1.18 + } 1.19 + break; 1.20 } 1.21 + case CX_DESTRUCTOR_ADVANCED: { 1.22 + CxIterator iter = cxListBegin(list); 1.23 + cx_foreach(void*, elem, iter) { 1.24 + list->advanced_destructor.func(list->advanced_destructor.data, elem); 1.25 + } 1.26 + break; 1.27 + } 1.28 + case CX_DESTRUCTOR_NONE: 1.29 + break; // nothing 1.30 } 1.31 + 1.32 list->cl->destructor(list); 1.33 cxFree(list->allocator, list); 1.34 - return NULL; 1.35 }