4 * Ullrich von Bassewitz, 17.06.1998
13 void* bsearch (const void* key, const void* base, size_t n, size_t size,
14 int (*cmp) (const void*, const void*))
23 while (first <= last) {
25 /* Set current to mid of range */
26 current = (last + first) / 2;
29 result = cmp ((void*) (((int) base) + current*size), key);
35 /* Found one entry that matches the search key. However there may be
36 * more than one entry with the same key value and ANSI guarantees
37 * that we return the first of a row of items with the same key.
44 /* Did we find the entry? */
45 return (void*) (found? ((int) base) + first*size : 0);