This commit is contained in:
Ebrahim Byagowi 2019-06-02 00:36:30 +04:30 committed by GitHub
parent 33d38e793e
commit 8278ff7dce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -607,15 +607,15 @@ template <typename ...Ts>
static inline void * static inline void *
hb_bsearch (const void *key, const void *base, hb_bsearch (const void *key, const void *base,
size_t nmemb, size_t size, size_t nmemb, size_t size,
int (*compar)(const void *_key, const void *_item, Ts... args), int (*compar)(const void *_key, const void *_item, Ts... _ds),
Ts... args) Ts... ds)
{ {
int min = 0, max = (int) nmemb - 1; int min = 0, max = (int) nmemb - 1;
while (min <= max) while (min <= max)
{ {
int mid = (min + max) / 2; int mid = (min + max) / 2;
const void *p = (const void *) (((const char *) base) + (mid * size)); const void *p = (const void *) (((const char *) base) + (mid * size));
int c = compar (key, p, args...); int c = compar (key, p, ds...);
if (c < 0) if (c < 0)
max = mid - 1; max = mid - 1;
else if (c > 0) else if (c > 0)