diff -r 08539b8273fa -r 4fbfac557df8 src/cx/list.h --- a/src/cx/list.h Mon Apr 18 16:56:29 2022 +0200 +++ b/src/cx/list.h Mon Apr 18 17:26:21 2022 +0200 @@ -71,13 +71,6 @@ */ CxAllocator const *allocator; /** - * An optional destructor for the list contents. - * - * @attention Read the documentation of the particular list implementation - * whether this destructor shall only destroy the contents or also free the memory. - */ - cx_destructor_func content_destructor; - /** * The comparator function for the elements. */ CxListComparator cmpfunc; @@ -93,6 +86,30 @@ * The capacity of the list (maximum number of elements). */ size_t capacity; + union { + /** + * An optional simple destructor for the list contents that admits the free() interface. + * + * @remark Set content_destructor_type to #CX_DESTRUCTOR_SIMPLE. + * + * @attention Read the documentation of the particular list implementation + * whether this destructor shall only destroy the contents or also free the memory. + */ + cx_destructor_func simple_destructor; + /** + * An optional advanced destructor for the list contents providing additional data. + * + * @remark Set content_destructor_type to #CX_DESTRUCTOR_ADVANCED. + * + * @attention Read the documentation of the particular list implementation + * whether this destructor shall only destroy the contents or also free the memory. + */ + cx_advanced_destructor advanced_destructor; + }; + /** + * The type of destructor to use. + */ + enum cx_destructor_type content_destructor_type; }; /** @@ -389,19 +406,17 @@ } /** - * Calls the list's destructor function for every element. - * If CxList.autofree_content is \c true, the elements are automatically free'd - * unless the content destructor function did not already do that. - * Similarly, if CxList.autofree is \c true, the list structure is free'd, unless - * the list destructor function did not already do that. + * Deallocates the memory of the specified list structure. + * + * Also calls content a destructor function, depending on the configuration + * in CxList.content_destructor_type. * * This function itself is a destructor function for the CxList. * - * @param list the list which contents shall be destroyed - * @return \p list if the list structure has not been free'd during the process + * @param list the list which shall be destroyed */ __attribute__((__nonnull__)) -CxList *cxListDestroy(CxList *list); +void cxListDestroy(CxList *list); #ifdef __cplusplus } /* extern "C" */