diff -r 16e2a3391e88 -r d4baf4dd55c3 src/list.c --- a/src/list.c Thu May 23 18:21:36 2024 +0200 +++ b/src/list.c Thu May 23 19:29:14 2024 +0200 @@ -80,11 +80,11 @@ } static int cx_pl_insert_iter( - struct cx_mut_iterator_s *iter, + struct cx_iterator_s *iter, void const *elem, int prepend ) { - struct cx_list_s *list = iter->src_handle; + struct cx_list_s *list = iter->src_handle.m; return list->climpl->insert_iter(iter, &elem, prepend); } @@ -148,7 +148,7 @@ static void *cx_pl_iter_current(void const *it) { struct cx_iterator_s const *iter = it; - void **ptr = iter->base.current_impl(it); + void **ptr = iter->current_impl(it); return ptr == NULL ? NULL : *ptr; } @@ -158,8 +158,8 @@ bool backwards ) { struct cx_iterator_s iter = list->climpl->iterator(list, index, backwards); - iter.base.current_impl = iter.base.current; - iter.base.current = cx_pl_iter_current; + iter.current_impl = iter.current; + iter.current = cx_pl_iter_current; return iter; } @@ -235,9 +235,9 @@ __attribute__((__unused__)) bool backwards ) { CxIterator iter = {0}; - iter.src_handle = list; + iter.src_handle.c = list; iter.index = index; - iter.base.valid = cx_emptyl_iter_valid; + iter.valid = cx_emptyl_iter_valid; return iter; } @@ -317,28 +317,20 @@ } } -CxMutIterator cxListMutIteratorAt( +CxIterator cxListMutIteratorAt( CxList *list, size_t index ) { CxIterator it = list->cl->iterator(list, index, false); - it.base.mutating = true; - - // we know the iterators share the same memory layout - CxMutIterator iter; - memcpy(&iter, &it, sizeof(CxMutIterator)); - return iter; + it.mutating = true; + return it; } -CxMutIterator cxListMutBackwardsIteratorAt( +CxIterator cxListMutBackwardsIteratorAt( CxList *list, size_t index ) { CxIterator it = list->cl->iterator(list, index, true); - it.base.mutating = true; - - // we know the iterators share the same memory layout - CxMutIterator iter; - memcpy(&iter, &it, sizeof(CxMutIterator)); - return iter; + it.mutating = true; + return it; }