This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Ping: [PATCH] Add inline bsearch expansion
On Sat, Feb 09, 2013 at 04:27:44PM +0100, Ondřej Bílka wrote:
> On Sat, Feb 09, 2013 at 02:23:59PM +0100, Andreas Schwab wrote:
> > 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.
> >
> here.
It's still broken. :-) Somehow, tab got substituted for space in the new
version. Also, somewhere along the way, the ChangeLog entry got lost
again...
> diff --git a/bits/stdlib-bsearch.h b/bits/stdlib-bsearch.h
> new file mode 100644
> index 0000000..b3ce741
> --- /dev/null
> +++ b/bits/stdlib-bsearch.h
> @@ -0,0 +1,43 @@
> +/* Perform binary search - inline version.
..snip..
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <http://www.gnu.org/licenses/>. */
> +__extern_inline
I'd add an empty line after the commit.
--
Petr "Pasky" Baudis
For every complex problem there is an answer that is clear,
simple, and wrong. -- H. L. Mencken