diff -r efbd59642577 -r 49a284f61e8c ucx/linked_list.c --- a/ucx/linked_list.c Fri Apr 21 21:25:32 2023 +0200 +++ b/ucx/linked_list.c Sun May 07 11:53:10 2023 +0200 @@ -56,7 +56,7 @@ return (void *) cur; } -size_t cx_linked_list_find( +ssize_t cx_linked_list_find( void const *start, ptrdiff_t loc_advance, ptrdiff_t loc_data, @@ -69,7 +69,7 @@ assert(cmp_func); void const *node = start; - size_t index = 0; + ssize_t index = 0; do { void *current = ll_data(node); if (cmp_func(current, elem) == 0) { @@ -78,7 +78,7 @@ node = ll_advance(node); index++; } while (node != NULL); - return index; + return -1; } void *cx_linked_list_first( @@ -355,6 +355,9 @@ // set start node ls = *begin; + // early exit when this list is empty + if (ls == NULL) return; + // check how many elements are already sorted lc = ls; size_t ln = 1; @@ -729,7 +732,7 @@ return node == NULL ? NULL : node->payload; } -static size_t cx_ll_find( +static ssize_t cx_ll_find( struct cx_list_s const *list, void const *elem ) {