summaryrefslogtreecommitdiff
path: root/ot_vector.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_vector.c')
-rw-r--r--ot_vector.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ot_vector.c b/ot_vector.c
index 154d1c8..f92f7ac 100644
--- a/ot_vector.c
+++ b/ot_vector.c
@@ -17,8 +17,8 @@
17#include "uint16.h" 17#include "uint16.h"
18 18
19static int vector_compare_peer(const void *peer1, const void *peer2 ) { 19static int vector_compare_peer(const void *peer1, const void *peer2 ) {
20 int32_t cmp = READ32(peer1,0) - READ32(peer2,0); 20 int32_t cmp = READ32(peer2,0) - READ32(peer1,0);
21 if (cmp == 0) cmp = READ16(peer1,4) - READ16(peer2,4); 21 if (cmp == 0) cmp = READ16(peer2,4) - READ16(peer1,4);
22 return cmp; 22 return cmp;
23} 23}
24 24
@@ -36,10 +36,10 @@ void *binary_search( const void * const key, const void * base, const size_t mem
36 *exactmatch = 1; 36 *exactmatch = 1;
37 37
38 while( mc ) { 38 while( mc ) {
39 int32_t cmp = key_cache - READ32(lookat,0); 39 int32_t cmp = READ32(lookat,0) - key_cache;
40 if (cmp == 0) { 40 if (cmp == 0) {
41 for( offs = 4; cmp == 0 && offs < compare_size; offs += 4 ) 41 for( offs = 4; cmp == 0 && offs < compare_size; offs += 4 )
42 cmp = READ32(key,offs) - READ32(lookat,offs); 42 cmp = READ32(lookat,offs) - READ32(key,offs);
43 if( cmp == 0 ) 43 if( cmp == 0 )
44 return (void *)lookat; 44 return (void *)lookat;
45 } 45 }
@@ -65,8 +65,8 @@ ot_peer *binary_search_peer( const ot_peer * const peer, const ot_peer * base, c
65 *exactmatch = 1; 65 *exactmatch = 1;
66 66
67 while( mc ) { 67 while( mc ) {
68 int32_t cmp = low - READ32(lookat,0); 68 int32_t cmp = READ32(lookat,0) - low;
69 if(cmp == 0) cmp = high - READ16(lookat,4); 69 if(cmp == 0) cmp = READ16(lookat,4) - high;
70 if(cmp == 0) return (ot_peer*)lookat; 70 if(cmp == 0) return (ot_peer*)lookat;
71 71
72 if (cmp < 0) { 72 if (cmp < 0) {