src/kv_list.c

changeset 1429
6e0c3a8a914a
parent 1419
e46406fd1b3c
--- a/src/kv_list.c	Fri Oct 17 15:04:56 2025 +0200
+++ b/src/kv_list.c	Fri Oct 17 16:53:24 2025 +0200
@@ -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;
 

mercurial