(trunk libT) inline the ptrarray one-liners

This commit is contained in:
Charles Kerr 2009-01-02 20:19:10 +00:00
parent 5e9af46612
commit d202c5ecea
3 changed files with 16 additions and 39 deletions

View File

@ -790,7 +790,7 @@ refillPulse( void * vtorrent )
blockIterator = blockIteratorNew( t );
peers = getPeersUploadingToClient( t, &peerCount );
webseedCount = tr_ptrArraySize( &t->webseeds );
webseeds = tr_memdup( tr_ptrArrayBase( &t->webseeds ),
webseeds = tr_memdup( TR_PTR_ARRAY_DATA( &t->webseeds ),
webseedCount * sizeof( tr_webseed* ) );
while( ( webseedCount || peerCount )

View File

@ -85,12 +85,6 @@ tr_ptrArrayPeek( tr_ptrArray * t,
return t->items;
}
void**
tr_ptrArrayBase( tr_ptrArray * t )
{
return t->items;
}
void*
tr_ptrArrayNth( tr_ptrArray* t,
int i )
@ -110,24 +104,6 @@ tr_ptrArrayBack( tr_ptrArray* t )
return tr_ptrArrayNth( t, t->n_items - 1 );
}
int
tr_ptrArraySize( const tr_ptrArray * t )
{
return t->n_items;
}
int
tr_ptrArrayEmpty( const tr_ptrArray * t )
{
return t->n_items == 0;
}
void
tr_ptrArrayClear( tr_ptrArray * t )
{
t->n_items = 0;
}
int
tr_ptrArrayInsert( tr_ptrArray * t,
void * ptr,
@ -151,13 +127,6 @@ tr_ptrArrayInsert( tr_ptrArray * t,
return pos;
}
int
tr_ptrArrayAppend( tr_ptrArray * t,
void * ptr )
{
return tr_ptrArrayInsert( t, ptr, -1 );
}
void*
tr_ptrArrayPop( tr_ptrArray* t )
{

View File

@ -29,6 +29,8 @@
#ifndef _TR_PTR_ARRAY_H_
#define _TR_PTR_ARRAY_H_
#include "transmission.h"
/**
* A simple pointer array that resizes itself dynamically.
*/
@ -67,16 +69,16 @@ void* tr_ptrArrayBack( tr_ptrArray * array );
void** tr_ptrArrayPeek( tr_ptrArray * array,
int * size );
void** tr_ptrArrayBase( tr_ptrArray * array );
void tr_ptrArrayClear( tr_ptrArray * array );
static inline void tr_ptrArrayClear( tr_ptrArray * a ) { a->n_items = 0; }
int tr_ptrArrayInsert( tr_ptrArray * array,
void * insertMe,
int pos );
int tr_ptrArrayAppend( tr_ptrArray * array,
void * appendMe );
static inline int tr_ptrArrayAppend( tr_ptrArray * array, void * appendMe )
{
return tr_ptrArrayInsert( array, appendMe, -1 );
}
void* tr_ptrArrayPop( tr_ptrArray * array );
@ -84,9 +86,15 @@ void tr_ptrArrayErase( tr_ptrArray * array,
int begin,
int end );
int tr_ptrArraySize( const tr_ptrArray* );
static inline int tr_ptrArraySize( const tr_ptrArray * a )
{
return a->n_items;
}
int tr_ptrArrayEmpty( const tr_ptrArray* );
static inline tr_bool tr_ptrArrayEmpty( const tr_ptrArray * a )
{
return tr_ptrArraySize(a) == 0;
}
int tr_ptrArrayInsertSorted( tr_ptrArray * array,
void * value,