undo part of r6616 to address the assertion failure reported by andersos and Waldorf

This commit is contained in:
Charles Kerr 2008-08-22 01:27:00 +00:00
parent b97717ffbf
commit d323a99cdd
4 changed files with 13 additions and 13 deletions

View File

@ -184,7 +184,7 @@ torrentIsLocked( const Torrent * t )
static int
compareAddresses( const struct in_addr * a, const struct in_addr * b )
{
return a->s_addr - b->s_addr;
return tr_compareUint32( a->s_addr, b->s_addr );
}
static int
@ -1770,13 +1770,12 @@ compareCandidates( const void * va, const void * vb )
{
const struct peer_atom * a = * (const struct peer_atom**) va;
const struct peer_atom * b = * (const struct peer_atom**) vb;
int i;
if( a->piece_data_time > b->piece_data_time ) return -1;
if( a->piece_data_time < b->piece_data_time ) return 1;
if(( i = a->numFails - b->numFails ))
return i;
if( a->numFails != b->numFails )
return a->numFails < b->numFails ? -1 : 1;
if( a->time != b->time )
return a->time < b->time ? -1 : 1;

View File

@ -117,14 +117,6 @@ struct peer_request
time_t time_requested;
};
static int
tr_compareUint32( uint32_t a, uint32_t b )
{
if( a < b ) return -1;
if( a > b ) return 1;
return 0;
}
static int
compareRequest( const void * va, const void * vb )
{

View File

@ -325,6 +325,14 @@ tr_set_compare( const void * va, size_t aCount,
****
***/
int
tr_compareUint32( uint32_t a, uint32_t b )
{
if( a < b ) return -1;
if( a > b ) return 1;
return 0;
}
int
tr_compareUint64( uint64_t a, uint64_t b )
{

View File

@ -218,7 +218,8 @@ void tr_set_compare( const void * a, size_t aCount,
tr_set_func in_b_cb,
tr_set_func in_both_cb,
void * userData );
int tr_compareUint32( uint32_t a, uint32_t b );
int tr_compareUint64( uint64_t a, uint64_t b );
int tr_strcmp( const void * a, const void * b );