mailing list of musl libc
 help / color / mirror / code / Atom feed
fe050ea30a223f4dd45070adae43cd59ac8a2243 blob 397 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
 
#include <stdlib.h>

void *bsearch(const void *key, const void *base, size_t nel, size_t width, int (*cmp)(const void *, const void *))
{
	void *try;
	int sign;
	while (nel > 0) {
		try = (char *)base + width*(nel/2);
		sign = cmp(key, try);
		if (sign < 0) {
			nel /= 2;
		} else if (sign > 0) {
			base = (char *)try + width;
			nel -= nel/2+1;
		} else {
			return try;
		}
	}
	return NULL;
}
debug log:

solving fe050ea3 ...
found fe050ea3 in https://git.vuxu.org/mirror/musl/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).