diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2010-03-31 14:24:25 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2010-03-31 14:24:25 -0700 |
commit | 1d168621a524e3937cd4e2a1cdec18a230b89a35 (patch) | |
tree | 313c8fd8c40432a78b6b99bc4c66175e56be4fef /libc/stdlib | |
parent | d04672513351af4eb302692e0f39fd5bd17191cb (diff) | |
parent | acdb052030d6e537e51d8b42e07b2a9e71e6ee42 (diff) | |
download | bionic-1d168621a524e3937cd4e2a1cdec18a230b89a35.zip bionic-1d168621a524e3937cd4e2a1cdec18a230b89a35.tar.gz bionic-1d168621a524e3937cd4e2a1cdec18a230b89a35.tar.bz2 |
merge from open-source master
Change-Id: I950e9aca87cbb0c35099b1d53cff6378bd0f26f4
Diffstat (limited to 'libc/stdlib')
-rw-r--r-- | libc/stdlib/bsearch.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libc/stdlib/bsearch.c b/libc/stdlib/bsearch.c index 8193d27..7eb6325 100644 --- a/libc/stdlib/bsearch.c +++ b/libc/stdlib/bsearch.c @@ -56,11 +56,11 @@ bsearch(const void *key, const void *base0, size_t nmemb, size_t size, for (lim = nmemb; lim != 0; lim >>= 1) { p = base + (lim >> 1) * size; cmp = (*compar)(key, p); - if (cmp == 0) - return ((void *)p); if (cmp > 0) { /* key > p: move right */ base = (char *)p + size; lim--; + } else if (cmp == 0) { + return ((void *)p); } /* else move left */ } return (NULL); |