fix that the support for NULL when creating mutating iterators was broken

Mon, 18 Aug 2025 23:08:56 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 18 Aug 2025 23:08:56 +0200
changeset 1345
79a865252b16
parent 1344
8afaeb395b3c
child 1346
2d24f7bae4c9

fix that the support for NULL when creating mutating iterators was broken

src/list.c file | annotate | diff | comparison | revisions
src/map.c file | annotate | diff | comparison | revisions
--- a/src/list.c	Mon Aug 18 23:06:27 2025 +0200
+++ b/src/list.c	Mon Aug 18 23:08:56 2025 +0200
@@ -476,6 +476,7 @@
         CxList *list,
         size_t index
 ) {
+    if (list == NULL) list = cxEmptyList;
     CxIterator it = list->cl->iterator(list, index, false);
     it.base.mutating = true;
     return it;
@@ -485,6 +486,7 @@
         CxList *list,
         size_t index
 ) {
+    if (list == NULL) list = cxEmptyList;
     CxIterator it = list->cl->iterator(list, index, true);
     it.base.mutating = true;
     return it;
--- a/src/map.c	Mon Aug 18 23:06:27 2025 +0200
+++ b/src/map.c	Mon Aug 18 23:08:56 2025 +0200
@@ -85,18 +85,21 @@
 // </editor-fold>
 
 CxMapIterator cxMapMutIteratorValues(CxMap *map) {
+    if (map == NULL) map = cxEmptyMap;
     CxMapIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_VALUES);
     it.base.mutating = true;
     return it;
 }
 
 CxMapIterator cxMapMutIteratorKeys(CxMap *map) {
+    if (map == NULL) map = cxEmptyMap;
     CxMapIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_KEYS);
     it.base.mutating = true;
     return it;
 }
 
 CxMapIterator cxMapMutIterator(CxMap *map) {
+    if (map == NULL) map = cxEmptyMap;
     CxMapIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS);
     it.base.mutating = true;
     return it;

mercurial