src/linked_list.c

changeset 453
bb144d08cd44
parent 451
db06dda7ac4d
child 456
227c2eabbef8
     1.1 --- a/src/linked_list.c	Sun Oct 03 13:07:48 2021 +0200
     1.2 +++ b/src/linked_list.c	Sun Oct 03 14:06:57 2021 +0200
     1.3 @@ -29,6 +29,7 @@
     1.4  #include "cx/linked_list.h"
     1.5  #include <stdint.h>
     1.6  #include <string.h>
     1.7 +#include <assert.h>
     1.8  
     1.9  /* LOW LEVEL LINKED LIST FUNCTIONS */
    1.10  
    1.11 @@ -61,16 +62,11 @@
    1.12      }
    1.13  }
    1.14  
    1.15 -int cx_linked_list_add(void **begin, void **end, ptrdiff_t loc_prev, ptrdiff_t loc_next, void *new_node) {
    1.16 +void cx_linked_list_add(void **begin, void **end, ptrdiff_t loc_prev, ptrdiff_t loc_next, void *new_node) {
    1.17      void *last = cx_linked_list_last(begin, end, loc_next);
    1.18      if (last == NULL) {
    1.19 -        if (begin == NULL) {
    1.20 -            // no current list and no begin ptr to write to - we don't find something to append to
    1.21 -            return 1;
    1.22 -        } else {
    1.23 -            // start fresh list
    1.24 -            *begin = new_node;
    1.25 -        }
    1.26 +        assert(begin != NULL);
    1.27 +        *begin = new_node;
    1.28      } else {
    1.29          // if there is a last node, update its next pointer
    1.30          void **next = CX_LL_PTR(last, loc_next);
    1.31 @@ -87,8 +83,6 @@
    1.32          void **prev = CX_LL_PTR(new_node, loc_prev);
    1.33          *prev = last;
    1.34      }
    1.35 -
    1.36 -    return 0;
    1.37  }
    1.38  
    1.39  /* HIGH LEVEL LINKED LIST IMPLEMENTATION */

mercurial