1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-31 03:12:44 +00:00

add more assertion tests to try to hunt down the tracker.c bug reported by John_Clay

This commit is contained in:
Charles Kerr 2007-09-28 15:05:42 +00:00
parent f0c9f9a99a
commit d9af0ff829

View file

@ -160,7 +160,16 @@ tr_ptrArrayLowerBound( const tr_ptrArray * t,
*exact_match = 0; *exact_match = 0;
return first; return first;
} }
static void
assertSortedAndUnique( const tr_ptrArray * t,
int compare(const void*, const void*) )
{
int i;
for( i=0; i<t->n_items-2; ++i )
assert( compare( t->items[i], t->items[i+1] ) < 0 );
}
int int
tr_ptrArrayInsertSorted( tr_ptrArray * t, tr_ptrArrayInsertSorted( tr_ptrArray * t,
@ -168,7 +177,9 @@ tr_ptrArrayInsertSorted( tr_ptrArray * t,
int compare(const void*,const void*) ) int compare(const void*,const void*) )
{ {
const int pos = tr_ptrArrayLowerBound( t, ptr, compare, NULL ); const int pos = tr_ptrArrayLowerBound( t, ptr, compare, NULL );
return tr_ptrArrayInsert( t, ptr, pos ); const int ret = tr_ptrArrayInsert( t, ptr, pos );
assertSortedAndUnique( t, compare );
return ret;
} }
void* void*
@ -193,5 +204,6 @@ tr_ptrArrayRemoveSorted( tr_ptrArray * t,
ret = t->items[pos]; ret = t->items[pos];
tr_ptrArrayErase( t, pos, pos+1 ); tr_ptrArrayErase( t, pos, pos+1 );
} }
assertSortedAndUnique( t, compare );
return ret; return ret;
} }