diff -r 6691e007cef7 -r 473d8cb58a6c ucx/linked_list.c --- a/ucx/linked_list.c Wed Dec 31 12:37:09 2025 +0100 +++ b/ucx/linked_list.c Wed Dec 31 16:40:12 2025 +0100 @@ -105,7 +105,7 @@ ) { cx_compare_func_wrapper wrapper = {cmp_func}; return cx_linked_list_find_c(start, loc_advance, loc_data, - elem, found_index, cx_acmp_wrap, &wrapper); + elem, found_index, cx_cmp_wrap, &wrapper); } void *cx_linked_list_first( @@ -254,19 +254,6 @@ } } -void cx_linked_list_insert_sorted( - void **begin, - void **end, - ptrdiff_t loc_prev, - ptrdiff_t loc_next, - void *new_node, - cx_compare_func cmp_func -) { - assert(ll_next(new_node) == NULL); - cx_linked_list_insert_sorted_chain( - begin, end, loc_prev, loc_next, new_node, cmp_func); -} - static void *cx_linked_list_insert_sorted_chain_impl( void **begin, void **end, @@ -409,6 +396,19 @@ return dup_begin; } +void cx_linked_list_insert_sorted( + void **begin, + void **end, + ptrdiff_t loc_prev, + ptrdiff_t loc_next, + void *new_node, + cx_compare_func cmp_func +) { + assert(ll_next(new_node) == NULL); + cx_linked_list_insert_sorted_chain( + begin, end, loc_prev, loc_next, new_node, cmp_func); +} + void cx_linked_list_insert_sorted_chain( void **begin, void **end, @@ -420,7 +420,7 @@ cx_compare_func_wrapper wrapper = {cmp_func}; cx_linked_list_insert_sorted_chain_impl( begin, end, loc_prev, loc_next, - insert_begin, cx_acmp_wrap, &wrapper, true); + insert_begin, cx_cmp_wrap, &wrapper, true); } int cx_linked_list_insert_unique( @@ -447,7 +447,63 @@ cx_compare_func_wrapper wrapper = {cmp_func}; return cx_linked_list_insert_sorted_chain_impl( begin, end, loc_prev, loc_next, - insert_begin, cx_acmp_wrap, &wrapper, false); + insert_begin, cx_cmp_wrap, &wrapper, false); +} + +void cx_linked_list_insert_sorted_c( + void **begin, + void **end, + ptrdiff_t loc_prev, + ptrdiff_t loc_next, + void *new_node, + cx_compare_func2 cmp_func, + void *context +) { + assert(ll_next(new_node) == NULL); + cx_linked_list_insert_sorted_chain_c( + begin, end, loc_prev, loc_next, new_node, cmp_func, context); +} + +void cx_linked_list_insert_sorted_chain_c( + void **begin, + void **end, + ptrdiff_t loc_prev, + ptrdiff_t loc_next, + void *insert_begin, + cx_compare_func2 cmp_func, + void *context +) { + cx_linked_list_insert_sorted_chain_impl( + begin, end, loc_prev, loc_next, + insert_begin, cmp_func, context, true); +} + +int cx_linked_list_insert_unique_c( + void **begin, + void **end, + ptrdiff_t loc_prev, + ptrdiff_t loc_next, + void *new_node, + cx_compare_func2 cmp_func, + void *context +) { + assert(ll_next(new_node) == NULL); + return NULL != cx_linked_list_insert_unique_chain_c( + begin, end, loc_prev, loc_next, new_node, cmp_func, context); +} + +void *cx_linked_list_insert_unique_chain_c( + void **begin, + void **end, + ptrdiff_t loc_prev, + ptrdiff_t loc_next, + void *insert_begin, + cx_compare_func2 cmp_func, + void *context +) { + return cx_linked_list_insert_sorted_chain_impl( + begin, end, loc_prev, loc_next, + insert_begin, cmp_func, context, false); } size_t cx_linked_list_remove_chain( @@ -661,7 +717,7 @@ cx_compare_func cmp_func ) { cx_compare_func_wrapper wrapper = {cmp_func}; - cx_linked_list_sort_c(begin, end, loc_prev, loc_next, loc_data, cx_acmp_wrap, &wrapper); + cx_linked_list_sort_c(begin, end, loc_prev, loc_next, loc_data, cx_cmp_wrap, &wrapper); } int cx_linked_list_compare_c( @@ -697,7 +753,7 @@ ) { cx_compare_func_wrapper wrapper = {cmp_func}; return cx_linked_list_compare_c(begin_left, begin_right, - loc_advance, loc_data, cx_acmp_wrap, &wrapper); + loc_advance, loc_data, cx_cmp_wrap, &wrapper); } void cx_linked_list_reverse( @@ -1328,8 +1384,8 @@ void cx_linked_list_extra_data(cx_linked_list *list, size_t len) { list->extra_data_len = len; - off_t loc_extra = list->loc_data + list->base.collection.elem_size; + off_t loc_extra = list->loc_data + (off_t) list->base.collection.elem_size; size_t alignment = alignof(void*); - size_t padding = alignment - (loc_extra % alignment); - list->loc_extra = loc_extra + padding; + size_t padding = alignment - ((size_t)loc_extra % alignment); + list->loc_extra = loc_extra + (off_t) padding; }