This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Add inline bsearch expansion
OndÅej BÃlka <neleai@seznam.cz> writes:
> +bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size,
> + int (*__compar) (const void *, const void *))
> +{
> + size_t __l, __u, __idx;
> + const void *__p;
> + int __comparison;
> +
> + __l = 0;
> + __u = __nmemb;
> + while (__l < __u)
> + {
> + __idx = (__l + __u) / 2;
> + __p = (void *) (((const char *) __base) + (__idx * __size));
> + __comparison = (*__compar) (__key, __p);
> + if (__comparison < 0)
> + __u = __idx;
> + else if (__comparison > 0)
> + __l = __idx + 1;
> + else
> + return (void *) __p;
> + }
Please use proper indentation.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."