src/linked_list.c

changeset 509
0d3c6075f82c
parent 508
8aea65ae1eaf
child 521
e5dc54131d55
--- a/src/linked_list.c	Sat Apr 09 16:37:43 2022 +0200
+++ b/src/linked_list.c	Sat Apr 09 18:02:53 2022 +0200
@@ -27,6 +27,7 @@
  */
 
 #include "cx/linked_list.h"
+#include "cx/utils.h"
 #include <stdint.h>
 #include <string.h>
 #include <assert.h>
@@ -323,7 +324,7 @@
 
     // Update pointer
     if (loc_prev >= 0) ll_prev(sorted[0]) = NULL;
-    for (size_t i = 0; i < length - 1; i++) {
+    cx_for_n (i, length - 1) {
         cx_linked_list_link(sorted[i], sorted[i + 1], loc_prev, loc_next);
     }
     ll_next(sorted[length - 1]) = NULL;
@@ -818,7 +819,7 @@
 ) {
     CxList *list = cxLinkedListCreate(allocator, comparator, item_size);
     if (list == NULL) return NULL;
-    for (size_t i = 0; i < num_items; i++) {
+    cx_for_n (i, num_items) {
         if (0 != cxListAdd(list, ((const unsigned char *) array) + i * item_size)) {
             return cx_ll_default_destructor(list);
         }

mercurial