mirror of
https://github.com/transmission/transmission
synced 2025-03-03 10:15:45 +00:00
(libT) a small, simple memory optimization
This commit is contained in:
parent
6b4170e970
commit
9cb73f8335
2 changed files with 31 additions and 35 deletions
|
@ -33,8 +33,8 @@ tr_ptrArrayNew( void )
|
|||
|
||||
p = tr_new( tr_ptrArray, 1 );
|
||||
p->n_items = 0;
|
||||
p->n_alloc = GROW;
|
||||
p->items = tr_new( void*, p->n_alloc );
|
||||
p->n_alloc = 0;
|
||||
p->items = NULL;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ tr_ptrArrayForeach( tr_ptrArray * t,
|
|||
int i;
|
||||
|
||||
assert( t );
|
||||
assert( t->items );
|
||||
assert( t->items || !t->n_items );
|
||||
assert( func );
|
||||
|
||||
for( i = 0; i < t->n_items; ++i )
|
||||
|
@ -70,7 +70,7 @@ tr_ptrArrayFree( tr_ptrArray * t,
|
|||
PtrArrayForeachFunc func )
|
||||
{
|
||||
assert( t );
|
||||
assert( t->items );
|
||||
assert( t->items || !t->n_items );
|
||||
|
||||
if( func )
|
||||
tr_ptrArrayForeach( t, func );
|
||||
|
|
|
@ -40,52 +40,48 @@ void tr_ptrArrayForeach(
|
|||
tr_ptrArray*,
|
||||
PtrArrayForeachFunc func );
|
||||
|
||||
void tr_ptrArrayFree(
|
||||
tr_ptrArray*,
|
||||
PtrArrayForeachFunc func );
|
||||
void tr_ptrArrayFree( tr_ptrArray * array,
|
||||
PtrArrayForeachFunc func );
|
||||
|
||||
void* tr_ptrArrayNth( tr_ptrArray*,
|
||||
int n );
|
||||
void* tr_ptrArrayNth( tr_ptrArray * array,
|
||||
int nth );
|
||||
|
||||
void* tr_ptrArrayBack( tr_ptrArray* );
|
||||
void* tr_ptrArrayBack( tr_ptrArray * array );
|
||||
|
||||
void** tr_ptrArrayPeek( tr_ptrArray*,
|
||||
int * size );
|
||||
void** tr_ptrArrayPeek( tr_ptrArray * array,
|
||||
int * size );
|
||||
|
||||
void** tr_ptrArrayBase( tr_ptrArray* );
|
||||
void** tr_ptrArrayBase( tr_ptrArray * array );
|
||||
|
||||
void tr_ptrArrayClear( tr_ptrArray* );
|
||||
void tr_ptrArrayClear( tr_ptrArray * array );
|
||||
|
||||
int tr_ptrArrayInsert( tr_ptrArray*,
|
||||
void*,
|
||||
int pos );
|
||||
int tr_ptrArrayInsert( tr_ptrArray * array,
|
||||
void * insertMe,
|
||||
int pos );
|
||||
|
||||
int tr_ptrArrayAppend( tr_ptrArray*,
|
||||
void* );
|
||||
int tr_ptrArrayAppend( tr_ptrArray * array,
|
||||
void * appendMe );
|
||||
|
||||
void* tr_ptrArrayPop( tr_ptrArray* );
|
||||
void* tr_ptrArrayPop( tr_ptrArray * array );
|
||||
|
||||
void tr_ptrArrayErase( tr_ptrArray*,
|
||||
int begin,
|
||||
int end );
|
||||
void tr_ptrArrayErase( tr_ptrArray * array,
|
||||
int begin,
|
||||
int end );
|
||||
|
||||
int tr_ptrArraySize( const tr_ptrArray* );
|
||||
|
||||
int tr_ptrArrayEmpty( const tr_ptrArray* );
|
||||
|
||||
int tr_ptrArrayInsertSorted( tr_ptrArray*,
|
||||
void*,
|
||||
int compare(const void*,
|
||||
const void*) );
|
||||
int tr_ptrArrayInsertSorted( tr_ptrArray * array,
|
||||
void * value,
|
||||
int compare(const void*, const void*) );
|
||||
|
||||
void* tr_ptrArrayRemoveSorted( tr_ptrArray*,
|
||||
void*,
|
||||
int compare(const void*,
|
||||
const void*) );
|
||||
void* tr_ptrArrayRemoveSorted( tr_ptrArray * array,
|
||||
void * value,
|
||||
int compare(const void*, const void*) );
|
||||
|
||||
void* tr_ptrArrayFindSorted( tr_ptrArray*,
|
||||
const void*,
|
||||
int compare(const void*,
|
||||
const void*) );
|
||||
void* tr_ptrArrayFindSorted( tr_ptrArray * array,
|
||||
const void * key,
|
||||
int compare(const void*, const void*) );
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue