1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
4 #include "alloc-util.h"
6 /* hey glibc, APIs with callbacks without a user pointer are so useless */
7 void *xbsearch_r(const void *key
, const void *base
, size_t nmemb
, size_t size
,
8 comparison_userdata_fn_t compar
, void *arg
) {
13 assert(!size_multiply_overflow(nmemb
, size
));
19 p
= (const uint8_t*) base
+ idx
* size
;
20 comparison
= compar(key
, p
, arg
);
23 else if (comparison
> 0)
31 int cmp_int(const int *a
, const int *b
) {