mirror of
https://github.com/transmission/transmission.git
synced 2026-05-08 09:39:08 +01:00
(trunk libT) inline the ptrarray one-liners
This commit is contained in:
@@ -790,7 +790,7 @@ refillPulse( void * vtorrent )
|
|||||||
blockIterator = blockIteratorNew( t );
|
blockIterator = blockIteratorNew( t );
|
||||||
peers = getPeersUploadingToClient( t, &peerCount );
|
peers = getPeersUploadingToClient( t, &peerCount );
|
||||||
webseedCount = tr_ptrArraySize( &t->webseeds );
|
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* ) );
|
webseedCount * sizeof( tr_webseed* ) );
|
||||||
|
|
||||||
while( ( webseedCount || peerCount )
|
while( ( webseedCount || peerCount )
|
||||||
|
|||||||
@@ -85,12 +85,6 @@ tr_ptrArrayPeek( tr_ptrArray * t,
|
|||||||
return t->items;
|
return t->items;
|
||||||
}
|
}
|
||||||
|
|
||||||
void**
|
|
||||||
tr_ptrArrayBase( tr_ptrArray * t )
|
|
||||||
{
|
|
||||||
return t->items;
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
void*
|
||||||
tr_ptrArrayNth( tr_ptrArray* t,
|
tr_ptrArrayNth( tr_ptrArray* t,
|
||||||
int i )
|
int i )
|
||||||
@@ -110,24 +104,6 @@ tr_ptrArrayBack( tr_ptrArray* t )
|
|||||||
return tr_ptrArrayNth( t, t->n_items - 1 );
|
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
|
int
|
||||||
tr_ptrArrayInsert( tr_ptrArray * t,
|
tr_ptrArrayInsert( tr_ptrArray * t,
|
||||||
void * ptr,
|
void * ptr,
|
||||||
@@ -151,13 +127,6 @@ tr_ptrArrayInsert( tr_ptrArray * t,
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
tr_ptrArrayAppend( tr_ptrArray * t,
|
|
||||||
void * ptr )
|
|
||||||
{
|
|
||||||
return tr_ptrArrayInsert( t, ptr, -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
void*
|
||||||
tr_ptrArrayPop( tr_ptrArray* t )
|
tr_ptrArrayPop( tr_ptrArray* t )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
#ifndef _TR_PTR_ARRAY_H_
|
#ifndef _TR_PTR_ARRAY_H_
|
||||||
#define _TR_PTR_ARRAY_H_
|
#define _TR_PTR_ARRAY_H_
|
||||||
|
|
||||||
|
#include "transmission.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple pointer array that resizes itself dynamically.
|
* A simple pointer array that resizes itself dynamically.
|
||||||
*/
|
*/
|
||||||
@@ -67,16 +69,16 @@ void* tr_ptrArrayBack( tr_ptrArray * array );
|
|||||||
void** tr_ptrArrayPeek( tr_ptrArray * array,
|
void** tr_ptrArrayPeek( tr_ptrArray * array,
|
||||||
int * size );
|
int * size );
|
||||||
|
|
||||||
void** tr_ptrArrayBase( tr_ptrArray * array );
|
static inline void tr_ptrArrayClear( tr_ptrArray * a ) { a->n_items = 0; }
|
||||||
|
|
||||||
void tr_ptrArrayClear( tr_ptrArray * array );
|
|
||||||
|
|
||||||
int tr_ptrArrayInsert( tr_ptrArray * array,
|
int tr_ptrArrayInsert( tr_ptrArray * array,
|
||||||
void * insertMe,
|
void * insertMe,
|
||||||
int pos );
|
int pos );
|
||||||
|
|
||||||
int tr_ptrArrayAppend( tr_ptrArray * array,
|
static inline int tr_ptrArrayAppend( tr_ptrArray * array, void * appendMe )
|
||||||
void * appendMe );
|
{
|
||||||
|
return tr_ptrArrayInsert( array, appendMe, -1 );
|
||||||
|
}
|
||||||
|
|
||||||
void* tr_ptrArrayPop( tr_ptrArray * array );
|
void* tr_ptrArrayPop( tr_ptrArray * array );
|
||||||
|
|
||||||
@@ -84,9 +86,15 @@ void tr_ptrArrayErase( tr_ptrArray * array,
|
|||||||
int begin,
|
int begin,
|
||||||
int end );
|
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,
|
int tr_ptrArrayInsertSorted( tr_ptrArray * array,
|
||||||
void * value,
|
void * value,
|
||||||
|
|||||||
Reference in New Issue
Block a user