diff -r 16e2a3391e88 -r d4baf4dd55c3 src/hash_map.c --- a/src/hash_map.c Thu May 23 18:21:36 2024 +0200 +++ b/src/hash_map.c Thu May 23 19:29:14 2024 +0200 @@ -252,7 +252,7 @@ static void *cx_hash_map_iter_current_value(void const *it) { struct cx_iterator_s const *iter = it; - struct cx_hash_map_s const *map = iter->src_handle; + struct cx_hash_map_s const *map = iter->src_handle.c; struct cx_hash_map_element_s *elm = iter->elem_handle; if (map->base.store_pointer) { return *(void **) elm->data; @@ -269,15 +269,13 @@ static void cx_hash_map_iter_next(void *it) { struct cx_iterator_s *iter = it; struct cx_hash_map_element_s *elm = iter->elem_handle; + struct cx_hash_map_s *map = iter->src_handle.m; // remove current element, if asked - if (iter->base.remove) { - // obtain mutable pointer to the map - struct cx_mut_iterator_s *miter = it; - struct cx_hash_map_s *map = miter->src_handle; + if (iter->remove) { // clear the flag - iter->base.remove = false; + iter->remove = false; // determine the next element struct cx_hash_map_element_s *next = elm->next; @@ -306,7 +304,6 @@ } // search the next bucket, if required - struct cx_hash_map_s const *map = iter->src_handle; while (elm == NULL && ++iter->slot < map->bucket_count) { elm = map->buckets[iter->slot]; } @@ -332,30 +329,30 @@ ) { CxIterator iter; - iter.src_handle = map; + iter.src_handle.c = map; iter.elem_count = map->size; switch (type) { case CX_MAP_ITERATOR_PAIRS: iter.elem_size = sizeof(CxMapEntry); - iter.base.current = cx_hash_map_iter_current_entry; + iter.current = cx_hash_map_iter_current_entry; break; case CX_MAP_ITERATOR_KEYS: iter.elem_size = sizeof(CxHashKey); - iter.base.current = cx_hash_map_iter_current_key; + iter.current = cx_hash_map_iter_current_key; break; case CX_MAP_ITERATOR_VALUES: iter.elem_size = map->item_size; - iter.base.current = cx_hash_map_iter_current_value; + iter.current = cx_hash_map_iter_current_value; break; default: assert(false); } - iter.base.valid = cx_hash_map_iter_valid; - iter.base.next = cx_hash_map_iter_next; - iter.base.remove = false; - iter.base.mutating = false; + iter.valid = cx_hash_map_iter_valid; + iter.next = cx_hash_map_iter_next; + iter.remove = false; + iter.mutating = false; iter.slot = 0; iter.index = 0;