src/linked_list.c

changeset 509
0d3c6075f82c
parent 508
8aea65ae1eaf
child 521
e5dc54131d55
     1.1 --- a/src/linked_list.c	Sat Apr 09 16:37:43 2022 +0200
     1.2 +++ b/src/linked_list.c	Sat Apr 09 18:02:53 2022 +0200
     1.3 @@ -27,6 +27,7 @@
     1.4   */
     1.5  
     1.6  #include "cx/linked_list.h"
     1.7 +#include "cx/utils.h"
     1.8  #include <stdint.h>
     1.9  #include <string.h>
    1.10  #include <assert.h>
    1.11 @@ -323,7 +324,7 @@
    1.12  
    1.13      // Update pointer
    1.14      if (loc_prev >= 0) ll_prev(sorted[0]) = NULL;
    1.15 -    for (size_t i = 0; i < length - 1; i++) {
    1.16 +    cx_for_n (i, length - 1) {
    1.17          cx_linked_list_link(sorted[i], sorted[i + 1], loc_prev, loc_next);
    1.18      }
    1.19      ll_next(sorted[length - 1]) = NULL;
    1.20 @@ -818,7 +819,7 @@
    1.21  ) {
    1.22      CxList *list = cxLinkedListCreate(allocator, comparator, item_size);
    1.23      if (list == NULL) return NULL;
    1.24 -    for (size_t i = 0; i < num_items; i++) {
    1.25 +    cx_for_n (i, num_items) {
    1.26          if (0 != cxListAdd(list, ((const unsigned char *) array) + i * item_size)) {
    1.27              return cx_ll_default_destructor(list);
    1.28          }

mercurial