1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

(trunk) check for duplicate ids when removing trackers

This commit is contained in:
Daniel Lee 2010-09-14 18:07:42 +00:00
parent ac53f4792f
commit 09df34e4c4

View file

@ -896,8 +896,9 @@ removeTrackers( tr_torrent * tor, tr_benc * ids )
{
int i;
int n;
int * tids;
int t = 0;
int dup = -1;
int * tids;
tr_benc * val;
tr_tracker_info * trackers;
tr_bool changed = FALSE;
@ -919,13 +920,15 @@ removeTrackers( tr_torrent * tor, tr_benc * ids )
tids[t++] = pos;
}
/* sort trackerIds because tr_removeElementFromArray changes indices as it removes */
/* sort trackerIds and remove from largest to smallest so there is no need to recacluate array indicies */
qsort( tids, t, sizeof(int), compareInt );
/* remove from largest trackerId to smallest */
while( t-- )
{
/* check for duplicates */
if( tids[t] == dup )
continue;
tr_removeElementFromArray( trackers, tids[t], sizeof( tr_tracker_info ), n-- );
dup = tids[t];
changed = TRUE;
}