From a9ab9b0c0dbd5de29d1aef9927cca92ac522d4cb Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Mon, 8 Dec 2008 02:23:21 +0000 Subject: Make all torrents in their buckets sorted again. --- ot_vector.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ot_vector.c') 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 @@ #include "uint16.h" static int vector_compare_peer(const void *peer1, const void *peer2 ) { - int32_t cmp = READ32(peer1,0) - READ32(peer2,0); - if (cmp == 0) cmp = READ16(peer1,4) - READ16(peer2,4); + int32_t cmp = READ32(peer2,0) - READ32(peer1,0); + if (cmp == 0) cmp = READ16(peer2,4) - READ16(peer1,4); return cmp; } @@ -36,10 +36,10 @@ void *binary_search( const void * const key, const void * base, const size_t mem *exactmatch = 1; while( mc ) { - int32_t cmp = key_cache - READ32(lookat,0); + int32_t cmp = READ32(lookat,0) - key_cache; if (cmp == 0) { for( offs = 4; cmp == 0 && offs < compare_size; offs += 4 ) - cmp = READ32(key,offs) - READ32(lookat,offs); + cmp = READ32(lookat,offs) - READ32(key,offs); if( cmp == 0 ) return (void *)lookat; } @@ -65,8 +65,8 @@ ot_peer *binary_search_peer( const ot_peer * const peer, const ot_peer * base, c *exactmatch = 1; while( mc ) { - int32_t cmp = low - READ32(lookat,0); - if(cmp == 0) cmp = high - READ16(lookat,4); + int32_t cmp = READ32(lookat,0) - low; + if(cmp == 0) cmp = READ16(lookat,4) - high; if(cmp == 0) return (ot_peer*)lookat; if (cmp < 0) { -- cgit v1.2.3