diff -r 6691e007cef7 -r 473d8cb58a6c ucx/cx/collection.h --- a/ucx/cx/collection.h Wed Dec 31 12:37:09 2025 +0100 +++ b/ucx/cx/collection.h Wed Dec 31 16:40:12 2025 +0100 @@ -40,10 +40,6 @@ #include "iterator.h" #include "compare.h" -#ifdef __cplusplus -extern "C" { -#endif - /** * Special constant used for creating collections that are storing pointers. */ @@ -204,7 +200,7 @@ */ #define cxSetAdvancedCompareFunc(c, func, data) \ (c)->collection.advanced_cmp = (cx_compare_func2) func; \ - (c)->collection.destructor_data = data + (c)->collection.cmp_data = data /** * Invokes the simple comparator function for two elements. @@ -316,8 +312,22 @@ if ((c)->collection.simple_destructor) cx_invoke_simple_destructor(c,e); \ if ((c)->collection.advanced_destructor) cx_invoke_advanced_destructor(c,e) -#ifdef __cplusplus -} // extern "C" -#endif +/** + * Invokes all available destructor functions for a specific element. + * + * Usually only used by collection implementations. There should be no need + * to invoke this macro manually. + * + * In contrast to cx_invoke_destructor(), this macro does not automatically + * dereference pointers to the elements when cxCollectionStoresPointers() + * returns true. + * + * @param c a pointer to a struct that contains #CX_COLLECTION_BASE + * @param e pointer to the element + */ +#define cx_invoke_destructor_raw(c, e) \ + if ((c)->collection.simple_destructor) (c)->collection.simple_destructor(e); \ + if ((c)->collection.advanced_destructor) (c)->collection.advanced_destructor((c)->collection.destructor_data, e) + #endif // UCX_COLLECTION_H