67 assert(loc_advance >= 0); |
67 assert(loc_advance >= 0); |
68 assert(loc_data >= 0); |
68 assert(loc_data >= 0); |
69 assert(cmp_func); |
69 assert(cmp_func); |
70 |
70 |
71 void const *node = start; |
71 void const *node = start; |
72 size_t index = 0; |
72 ssize_t index = 0; |
73 do { |
73 do { |
74 void *current = ll_data(node); |
74 void *current = ll_data(node); |
75 if (cmp_func(current, elem) == 0) { |
75 if (cmp_func(current, elem) == 0) { |
76 return index; |
76 return index; |
77 } |
77 } |
78 node = ll_advance(node); |
78 node = ll_advance(node); |
79 index++; |
79 index++; |
80 } while (node != NULL); |
80 } while (node != NULL); |
81 return index; |
81 return -1; |
82 } |
82 } |
83 |
83 |
84 void *cx_linked_list_first( |
84 void *cx_linked_list_first( |
85 void const *node, |
85 void const *node, |
86 ptrdiff_t loc_prev |
86 ptrdiff_t loc_prev |
727 cx_linked_list *ll = (cx_linked_list *) list; |
727 cx_linked_list *ll = (cx_linked_list *) list; |
728 cx_linked_list_node *node = cx_ll_node_at(ll, index); |
728 cx_linked_list_node *node = cx_ll_node_at(ll, index); |
729 return node == NULL ? NULL : node->payload; |
729 return node == NULL ? NULL : node->payload; |
730 } |
730 } |
731 |
731 |
732 static size_t cx_ll_find( |
732 static ssize_t cx_ll_find( |
733 struct cx_list_s const *list, |
733 struct cx_list_s const *list, |
734 void const *elem |
734 void const *elem |
735 ) { |
735 ) { |
736 return cx_linked_list_find(((cx_linked_list *) list)->begin, |
736 return cx_linked_list_find(((cx_linked_list *) list)->begin, |
737 CX_LL_LOC_NEXT, CX_LL_LOC_DATA, |
737 CX_LL_LOC_NEXT, CX_LL_LOC_DATA, |