Ignore:
Timestamp:
Sep 28, 2007, 3:05:42 PM (13 years ago)
Author:
charles
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/ptrarray.c

    r3105 r3221  
    161161
    162162    return first;
    163 }
     163}
     164
     165static void
     166assertSortedAndUnique( const tr_ptrArray * t,
     167                       int compare(const void*, const void*) )
     168{
     169    int i;
     170    for( i=0; i<t->n_items-2; ++i )
     171        assert( compare( t->items[i], t->items[i+1] ) < 0 );
     172}
    164173
    165174int
     
    169178{
    170179    const int pos = tr_ptrArrayLowerBound( t, ptr, compare, NULL );
    171     return tr_ptrArrayInsert( t, ptr, pos );
     180    const int ret = tr_ptrArrayInsert( t, ptr, pos );
     181    assertSortedAndUnique( t, compare );
     182    return ret;
    172183}
    173184
     
    194205        tr_ptrArrayErase( t, pos, pos+1 );
    195206    }
     207    assertSortedAndUnique( t, compare );
    196208    return ret;
    197209}
Note: See TracChangeset for help on using the changeset viewer.