summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ot_vector.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ot_vector.c b/ot_vector.c
index 056fafb..66797f1 100644
--- a/ot_vector.c
+++ b/ot_vector.c
@@ -27,10 +27,10 @@ static int vector_compare_peer(const void *peer1, const void *peer2 ) {
27*/ 27*/
28void *binary_search( const void * const key, const void * base, const size_t member_count, const size_t member_size, 28void *binary_search( const void * const key, const void * base, const size_t member_count, const size_t member_size,
29 size_t compare_size, int *exactmatch ) { 29 size_t compare_size, int *exactmatch ) {
30 size_t interval = member_count * member_size; 30 size_t interval = member_count;
31 31
32 while( interval ) { 32 while( interval ) {
33 uint8_t *lookat = ((uint8_t*)base) + interval / 2; 33 uint8_t *lookat = ((uint8_t*)base) + member_size * ( interval / 2 );
34 int cmp = memcmp( lookat, key, compare_size ); 34 int cmp = memcmp( lookat, key, compare_size );
35 if(cmp == 0 ) { 35 if(cmp == 0 ) {
36 base = lookat; 36 base = lookat;
@@ -38,7 +38,7 @@ void *binary_search( const void * const key, const void * base, const size_t mem
38 } 38 }
39 if(cmp < 0) { 39 if(cmp < 0) {
40 base = lookat + member_size; 40 base = lookat + member_size;
41 interval -= member_size; 41 interval --;
42 } 42 }
43 interval /= 2; 43 interval /= 2;
44 } 44 }