--- a/ucx/kv_list.c Sun Oct 19 21:20:08 2025 +0200 +++ b/ucx/kv_list.c Mon Nov 10 21:52:51 2025 +0100 @@ -152,7 +152,7 @@ const void *elem, int prepend ) { - cx_kv_list *kv_list = iter->src_handle.m; + cx_kv_list *kv_list = iter->src_handle; return kv_list->list_methods->insert_iter(iter, elem, prepend); } @@ -259,7 +259,7 @@ struct cx_iterator_s *iter = it; if (iter->base.remove) { // remove the assigned key from the map before calling the actual function - cx_kv_list *kv_list = iter->src_handle.m; + cx_kv_list *kv_list = iter->src_handle; cx_kv_list_update_destructors(kv_list); char *node = iter->elem_handle; CxHashKey *key = cx_kv_list_loc_key(kv_list, node + kv_list->list.loc_data); @@ -267,6 +267,7 @@ kv_list->map_methods->remove(&kv_list->map->map_base.base, *key, NULL); } } + // note that we do not clear the remove flag, because the next_impl will do that iter->base.next_impl(it); } @@ -397,7 +398,7 @@ static void cx_kvl_iter_next(void *it) { CxMapIterator *iter = it; - cx_kv_list *kv_list = ((struct cx_kv_list_map_s*)iter->map.m)->list; + cx_kv_list *kv_list = ((struct cx_kv_list_map_s*)iter->map)->list; // find the next list entry that has a key assigned CxHashKey *key = NULL; @@ -458,7 +459,7 @@ CxMapIterator iter = {0}; iter.type = type; - iter.map.c = map; + iter.map = (CxMap*)map; // although we iterate over the list, we only report that many elements that have a key in the map iter.elem_count = map->collection.size; @@ -479,6 +480,7 @@ assert(false); // LCOV_EXCL_LINE } + iter.base.allow_remove = true; iter.base.next = cx_kvl_iter_next; iter.base.valid = cx_kvl_iter_valid; @@ -507,6 +509,15 @@ return iter; } +static int cx_kvl_change_capacity(struct cx_list_s *list, + cx_attr_unused size_t cap) { + // since our backing list is a linked list, we don't need to do much here, + // but rehashing the map is quite useful + cx_kv_list *kv_list = (cx_kv_list*)list; + cxMapRehash(&kv_list->map->map_base.base); + return 0; +} + static cx_list_class cx_kv_list_class = { cx_kvl_deallocate, cx_kvl_insert_element, @@ -522,6 +533,7 @@ cx_kvl_sort, NULL, cx_kvl_reverse, + cx_kvl_change_capacity, cx_kvl_iterator, };