3 * This file lifted in toto from 'Dlibs' on the atari ST (RdeBath)
6 * Dale Schumacher 399 Beacon Ave.
7 * (alias: Dalnefre') St. Paul, MN 55104
8 * dal@syntel.UUCP United States of America
9 * "It's not reality that's important, but how you perceive things."
13 static int _bsearch
; /* index of element found, or where to
17 bsearch(key
, base
, num
, size
, cmp
)
18 register char *key
; /* item to search for */
19 register char *base
; /* base address */
20 int num
; /* number of elements */
21 register int size
; /* element size in bytes */
22 register int (*cmp
) (); /* comparison function */
24 register int a
, b
, c
, dir
;
30 c
= (a
+ b
) >> 1; /* == ((a + b) / 2) */
31 if (dir
= (*cmp
) ((base
+ (c
* size
)), key
))
41 return (base
+ (c
* size
));