src/array_list.c

changeset 1162
e3bb67b72d33
parent 1111
78eeeb950883
child 1163
68ff0839bc6a
--- a/src/array_list.c	Sun Jan 26 14:37:07 2025 +0100
+++ b/src/array_list.c	Mon Jan 27 20:27:39 2025 +0100
@@ -856,7 +856,7 @@
     }
 }
 
-static ssize_t cx_arl_find_remove(
+static size_t cx_arl_find_remove(
         struct cx_list_s *list,
         const void *elem,
         bool remove
@@ -865,14 +865,14 @@
     assert(list->collection.size < SIZE_MAX / 2);
     char *cur = ((const cx_array_list *) list)->data;
 
-    for (ssize_t i = 0; i < (ssize_t) list->collection.size; i++) {
+    for (size_t i = 0; i < list->collection.size; i++) {
         if (0 == list->collection.cmpfunc(elem, cur)) {
             if (remove) {
                 if (1 == cx_arl_remove(list, i, 1, NULL)) {
                     return i;
                 } else {
                     // should be unreachable
-                    return -1;  // LCOV_EXCL_LINE
+                    return list->collection.size;  // LCOV_EXCL_LINE
                 }
             } else {
                 return i;
@@ -881,7 +881,7 @@
         cur += list->collection.elem_size;
     }
 
-    return -1;
+    return list->collection.size;
 }
 
 static void cx_arl_sort(struct cx_list_s *list) {

mercurial