diff -r 2e8878770de0 -r 8aea65ae1eaf src/linked_list.c --- a/src/linked_list.c Sun Mar 06 13:57:36 2022 +0100 +++ b/src/linked_list.c Sat Apr 09 16:37:43 2022 +0200 @@ -40,7 +40,7 @@ #define ll_data(node) (follow_ptr?CX_LL_PTR(node, loc_data):(((char*)node)+loc_data)) void *cx_linked_list_at( - void *start, + void const *start, size_t start_index, ptrdiff_t loc_advance, size_t index @@ -48,12 +48,12 @@ assert(start != NULL); assert(loc_advance >= 0); size_t i = start_index; - void *cur = start; + void const *cur = start; while (i != index && cur != NULL) { cur = ll_advance(cur); i < index ? i++ : i--; } - return cur; + return (void *) cur; } size_t cx_linked_list_find( @@ -83,42 +83,42 @@ } void *cx_linked_list_first( - void *node, + void const *node, ptrdiff_t loc_prev ) { return cx_linked_list_last(node, loc_prev); } void *cx_linked_list_last( - void *node, + void const *node, ptrdiff_t loc_next ) { assert(node != NULL); assert(loc_next >= 0); - void *cur = node; - void *last; + void const *cur = node; + void const *last; do { last = cur; } while ((cur = ll_next(cur)) != NULL); - return last; + return (void *) last; } void *cx_linked_list_prev( - void *begin, + void const *begin, ptrdiff_t loc_next, - void *node + void const *node ) { assert(begin != NULL); assert(node != NULL); assert(loc_next >= 0); if (begin == node) return NULL; - void *cur = begin; - void *next; + void const *cur = begin; + void const *next; while (1) { next = ll_next(cur); - if (next == node) return cur; + if (next == node) return (void *) cur; cur = next; } } @@ -294,6 +294,7 @@ const size_t sbo_len = 1024; void *sbo[sbo_len]; void **sorted = (length >= sbo_len) ? malloc(sizeof(void *) * length) : sbo; + if (sorted == NULL) abort(); void *rc, *lc; lc = ls; @@ -772,7 +773,7 @@ } CxList *cxLinkedListCreate( - CxAllocator *allocator, + CxAllocator const *allocator, CxListComparator comparator, size_t item_size ) { @@ -791,7 +792,7 @@ } CxList *cxPointerLinkedListCreate( - CxAllocator *allocator, + CxAllocator const *allocator, CxListComparator comparator ) { cx_linked_list *list = cxCalloc(allocator, 1, sizeof(cx_linked_list)); @@ -809,7 +810,7 @@ } CxList *cxLinkedListFromArray( - CxAllocator *allocator, + CxAllocator const *allocator, CxListComparator comparator, size_t item_size, size_t num_items,