src/cx/list.h

changeset 1343
b2ba79f4cb62
parent 1341
dc88d2ece7e4
child 1346
2d24f7bae4c9
--- a/src/cx/list.h	Sun Aug 17 23:10:25 2025 +0200
+++ b/src/cx/list.h	Mon Aug 18 23:00:55 2025 +0200
@@ -872,18 +872,18 @@
  *
  * The returned iterator is position-aware.
  *
- * If the index is out of range, a past-the-end iterator will be returned.
+ * If the index is out of range or @p list is @c NULL, a past-the-end iterator will be returned.
  *
  * @param list the list
  * @param index the index where the iterator shall point at
  * @return a new iterator
  */
-cx_attr_nonnull
 cx_attr_nodiscard
 static inline CxIterator cxListIteratorAt(
         const CxList *list,
         size_t index
 ) {
+    if (list == NULL) list = cxEmptyList;
     return list->cl->iterator(list, index, false);
 }
 
@@ -892,18 +892,18 @@
  *
  * The returned iterator is position-aware.
  *
- * If the index is out of range, a past-the-end iterator will be returned.
+ * If the index is out of range or @p list is @c NULL, a past-the-end iterator will be returned.
  *
  * @param list the list
  * @param index the index where the iterator shall point at
  * @return a new iterator
  */
-cx_attr_nonnull
 cx_attr_nodiscard
 static inline CxIterator cxListBackwardsIteratorAt(
         const CxList *list,
         size_t index
 ) {
+    if (list == NULL) list = cxEmptyList;
     return list->cl->iterator(list, index, true);
 }
 

mercurial