From ed7685dd1aa04b31e025feae8cd9e97fd2114545 Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Wed, 20 Aug 2008 13:45:52 +0000 Subject: [PATCH] Make tr_bitfieldHas() a macro --- libtransmission/peer-mgr.c | 8 ++++---- libtransmission/peer-mgr.h | 4 ++-- libtransmission/peer-msgs.c | 2 +- libtransmission/test-fastset.c | 2 +- libtransmission/utils-test.c | 4 ++-- libtransmission/utils.c | 7 ------- libtransmission/utils.h | 5 ++++- 7 files changed, 14 insertions(+), 18 deletions(-) diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 98f94134a..866b276bc 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -594,7 +594,7 @@ getPreferredPieces( Torrent * t, for( j=0; jpiece = piece; @@ -1099,7 +1099,7 @@ tr_peerMgrCompactToPex( const void * compact, void tr_peerMgrSetBlame( tr_peerMgr * manager, const uint8_t * torrentHash, - int pieceIndex, + tr_piece_index_t pieceIndex, int success ) { if( !success ) @@ -1296,9 +1296,9 @@ void tr_peerMgrTorrentAvailability( const tr_peerMgr * manager, const uint8_t * torrentHash, int8_t * tab, - int tabCount ) + unsigned int tabCount ) { - int i; + tr_piece_index_t i; const Torrent * t; const tr_torrent * tor; float interval; diff --git a/libtransmission/peer-mgr.h b/libtransmission/peer-mgr.h index 9e1190856..dfaa9cb78 100644 --- a/libtransmission/peer-mgr.h +++ b/libtransmission/peer-mgr.h @@ -72,7 +72,7 @@ void tr_peerMgrAddPex( tr_peerMgr * manager, void tr_peerMgrSetBlame( tr_peerMgr * manager, const uint8_t * torrentHash, - int pieceIndex, + tr_piece_index_t pieceIndex, int success ); int tr_peerMgrGetPeers( tr_peerMgr * manager, @@ -94,7 +94,7 @@ void tr_peerMgrRemoveTorrent( tr_peerMgr * manager, void tr_peerMgrTorrentAvailability( const tr_peerMgr * manager, const uint8_t * torrentHash, int8_t * tab, - int tabCount ); + unsigned int tabCount ); struct tr_bitfield* tr_peerMgrGetAvailable( const tr_peerMgr * manager, const uint8_t * torrentHash ); diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index de9dbd6f4..079dce523 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -522,7 +522,7 @@ fireCancelledReq( tr_peermsgs * msgs, const tr_piece_index_t pieceIndex ) static int isPieceInteresting( const tr_peermsgs * peer, - int piece ) + tr_piece_index_t piece ) { const tr_torrent * torrent = peer->torrent; diff --git a/libtransmission/test-fastset.c b/libtransmission/test-fastset.c index 2ec86f78d..3c5e4aa68 100644 --- a/libtransmission/test-fastset.c +++ b/libtransmission/test-fastset.c @@ -28,7 +28,7 @@ main( void ) struct in_addr addr; uint32_t sz; uint32_t k; - int pieces[] = { 1059,431,808,1217,287,376,1188,353,508 }; + tr_piece_index_t pieces[] = { 1059,431,808,1217,287,376,1188,353,508 }; for( i=0; ibits) && ((high)<(bitfield)->bitCount ) ) +#define tr_bitfieldHas(bitfield,nth) \ + ( tr_bitfieldTestFast( bitfield, nth ) && \ + tr_bitfieldHasFast( bitfield, nth ) ) + double tr_getRatio( double numerator, double denominator ); #endif -- 2.40.0