Changeset 7524 for trunk/libtransmission/bandwidth.c
- Timestamp:
- Dec 29, 2008, 8:54:36 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/bandwidth.c
r7495 r7524 99 99 int magicNumber; 100 100 tr_session * session; 101 tr_ptrArray *children; /* struct tr_bandwidth */102 tr_ptrArray *peers; /* tr_peerIo */101 tr_ptrArray children; /* struct tr_bandwidth */ 102 tr_ptrArray peers; /* tr_peerIo */ 103 103 }; 104 104 … … 131 131 tr_bandwidth * b = tr_new0( tr_bandwidth, 1 ); 132 132 b->session = session; 133 b->children = tr_ptrArrayNew( );134 b->peers = tr_ptrArrayNew( );133 b->children = TR_PTR_ARRAY_INIT; 134 b->peers = TR_PTR_ARRAY_INIT; 135 135 b->magicNumber = MAGIC_NUMBER; 136 136 b->band[TR_UP].honorParentLimits = TRUE; … … 146 146 147 147 tr_bandwidthSetParent( b, NULL ); 148 tr_ptrArray Free(b->peers, NULL );149 tr_ptrArray Free(b->children, NULL );148 tr_ptrArrayDestruct( &b->peers, NULL ); 149 tr_ptrArrayDestruct( &b->children, NULL ); 150 150 b->magicNumber = 0xDEAD; 151 151 tr_free( b ); … … 167 167 assert( tr_isBandwidth( b->parent ) ); 168 168 169 tr_ptrArrayRemoveSorted( b->parent->children, b, comparePointers );169 tr_ptrArrayRemoveSorted( &b->parent->children, b, comparePointers ); 170 170 b->parent = NULL; 171 171 } … … 176 176 assert( parent->parent != b ); 177 177 178 tr_ptrArrayInsertSorted( parent->children, b, comparePointers );178 tr_ptrArrayInsertSorted( &parent->children, b, comparePointers ); 179 179 b->parent = parent; 180 180 } … … 270 270 { 271 271 int i; 272 const int n = tr_ptrArraySize(b->peers );272 const int n = TR_PTR_ARRAY_LENGTH( &b->peers ); 273 273 for( i=0; i<n; ++i ) 274 tr_ptrArrayAppend( peer_pool, tr_ptrArrayNth( b->peers, i ) );274 tr_ptrArrayAppend( peer_pool, tr_ptrArrayNth( &b->peers, i ) ); 275 275 } 276 276 … … 282 282 /* all children should reallocate too */ 283 283 if( 1 ) { 284 int i, n=0; 285 struct tr_bandwidth ** children = (struct tr_bandwidth**) tr_ptrArrayPeek( b->children, &n ); 284 int i; 285 struct tr_bandwidth ** children = (struct tr_bandwidth**) TR_PTR_ARRAY_DATA( &b->children ); 286 const int n = TR_PTR_ARRAY_LENGTH( &b->children ); 286 287 for( i=0; i<n; ++i ) 287 288 allocateBandwidth( children[i], dir, period_msec, peer_pool ); … … 295 296 { 296 297 int i, n, peerCount; 297 tr_ptrArray * tmp;298 tr_ptrArray tmp = TR_PTR_ARRAY_INIT; 298 299 struct tr_peerIo ** peers; 299 300 const uint64_t now = tr_date( ); … … 304 305 * 1. allocate bandwidth to b and its subtree 305 306 * 2. accumulate an array of all the peerIos from b and its subtree. */ 306 tmp = tr_ptrArrayNew( ); 307 allocateBandwidth( b, dir, period_msec, tmp ); 308 peers = (struct tr_peerIo**) tr_ptrArrayPeek( tmp, &peerCount ); 307 allocateBandwidth( b, dir, period_msec, &tmp ); 308 peers = (struct tr_peerIo**) tr_ptrArrayPeek( &tmp, &peerCount ); 309 309 310 310 /* Stop all peers from listening for the socket to be ready for IO. … … 348 348 349 349 /* cleanup */ 350 tr_ptrArray Free(tmp, NULL );350 tr_ptrArrayDestruct( &tmp, NULL ); 351 351 } 352 352 … … 362 362 assert( tr_isPeerIo( peerIo ) ); 363 363 364 tr_ptrArrayInsertSorted( b->peers, peerIo, comparePointers );364 tr_ptrArrayInsertSorted( &b->peers, peerIo, comparePointers ); 365 365 } 366 366 … … 372 372 assert( tr_isPeerIo( peerIo ) ); 373 373 374 tr_ptrArrayRemoveSorted( b->peers, peerIo, comparePointers );374 tr_ptrArrayRemoveSorted( &b->peers, peerIo, comparePointers ); 375 375 } 376 376
Note: See TracChangeset
for help on using the changeset viewer.