mirror of
https://github.com/transmission/transmission
synced 2025-03-20 18:55:32 +00:00
(trunk libT) #2958 "Minimize use of tr_ptrArray in critical parts of the code" -- accept patch from sadface to make tr_ptrArrayInsert() a little cleaner
This commit is contained in:
parent
1d8d9d8447
commit
64a847baf0
1 changed files with 6 additions and 6 deletions
|
@ -73,18 +73,18 @@ tr_ptrArrayInsert( tr_ptrArray * t,
|
|||
void * ptr,
|
||||
int pos )
|
||||
{
|
||||
if( pos < 0 || pos > t->n_items )
|
||||
pos = t->n_items;
|
||||
|
||||
if( t->n_items >= t->n_alloc )
|
||||
{
|
||||
t->n_alloc = MAX( FLOOR, t->n_alloc * 2 );
|
||||
t->items = tr_renew( void*, t->items, t->n_alloc );
|
||||
}
|
||||
|
||||
memmove( t->items + pos + 1,
|
||||
t->items + pos,
|
||||
sizeof( void* ) * ( t->n_items - pos ) );
|
||||
if( pos < 0 || pos > t->n_items )
|
||||
pos = t->n_items;
|
||||
else
|
||||
memmove( t->items + pos + 1,
|
||||
t->items + pos,
|
||||
sizeof( void* ) * ( t->n_items - pos ) );
|
||||
|
||||
t->items[pos] = ptr;
|
||||
t->n_items++;
|
||||
|
|
Loading…
Add table
Reference in a new issue