Ping: [PATCH] Add inline bsearch expansion

Andreas Schwab schwab@linux-m68k.org
Sat Feb 9 13:24:00 GMT 2013


Ondřej Bílka <neleai@seznam.cz> writes:

> +void *
> +bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size,
> +   __compar_fn_t __compar)
> +{
> +  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 fix the 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."



More information about the Libc-alpha mailing list