diff -r 08539b8273fa -r 4fbfac557df8 src/list.c --- a/src/list.c Mon Apr 18 16:56:29 2022 +0200 +++ b/src/list.c Mon Apr 18 17:26:21 2022 +0200 @@ -28,14 +28,26 @@ #include "cx/list.h" -CxList *cxListDestroy(CxList *list) { - if (list->content_destructor != NULL) { - CxIterator iter = cxListBegin(list); - cx_foreach(void*, elem, iter) { - list->content_destructor(elem); +void cxListDestroy(CxList *list) { + switch (list->content_destructor_type) { + case CX_DESTRUCTOR_SIMPLE: { + CxIterator iter = cxListBegin(list); + cx_foreach(void*, elem, iter) { + list->simple_destructor(elem); + } + break; } + case CX_DESTRUCTOR_ADVANCED: { + CxIterator iter = cxListBegin(list); + cx_foreach(void*, elem, iter) { + list->advanced_destructor.func(list->advanced_destructor.data, elem); + } + break; + } + case CX_DESTRUCTOR_NONE: + break; // nothing } + list->cl->destructor(list); cxFree(list->allocator, list); - return NULL; }