--- a/src/ucx/list.c Sat Nov 29 19:03:52 2025 +0100 +++ b/src/ucx/list.c Sun Nov 30 18:25:55 2025 +0100 @@ -185,6 +185,14 @@ return ptr == NULL ? NULL : *ptr; } +static int cx_pl_change_capacity(struct cx_list_s *list, size_t cap) { + if (list->climpl->change_capacity == NULL) { + return 0; + } else { + return list->climpl->change_capacity(list, cap); + } +} + static struct cx_iterator_s cx_pl_iterator( const struct cx_list_s *list, size_t index, @@ -211,6 +219,7 @@ cx_pl_sort, cx_pl_compare, cx_pl_reverse, + cx_pl_change_capacity, cx_pl_iterator, }; // </editor-fold> @@ -267,6 +276,7 @@ cx_emptyl_noop, NULL, cx_emptyl_noop, + NULL, cx_emptyl_iterator, }; @@ -1020,7 +1030,7 @@ CxIterator src_iter = cxListIterator(src); CxIterator other_iter = cxListIterator(other); while (cxIteratorValid(src_iter) || cxIteratorValid(other_iter)) { - void *src_elem, *other_elem; + void *src_elem = NULL, *other_elem = NULL; int d; if (!cxIteratorValid(src_iter)) { other_elem = cxIteratorCurrent(other_iter); @@ -1102,3 +1112,20 @@ int cxListUnionSimple(CxList *dst, const CxList *src, const CxList *other) { return cxListUnion(dst, src, other, use_simple_clone_func(src)); } + +int cxListReserve(CxList *list, size_t capacity) { + if (list->cl->change_capacity == NULL) { + return 0; + } + if (capacity <= cxCollectionSize(list)) { + return 0; + } + return list->cl->change_capacity(list, capacity); +} + +int cxListShrink(CxList *list) { + if (list->cl->change_capacity == NULL) { + return 0; + } + return list->cl->change_capacity(list, cxCollectionSize(list)); +}