Ignore:
Timestamp:
Dec 29, 2008, 9:51:54 AM (12 years ago)
Author:
charles
Message:

(trunk libT) avoid some unnecessary memory fragmentation... for composited objects that have a tr_bitfield, contain it directly rather than a pointer to one allocated elsewhere on the heap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r7524 r7525  
    538538    tor->error   = 0;
    539539
    540     tor->checkedPieces = tr_bitfieldNew( tor->info.pieceCount );
     540    tr_bitfieldConstruct( &tor->checkedPieces, tor->info.pieceCount );
    541541    tr_torrentUncheck( tor );
    542542
     
    10641064    tor->tracker = NULL;
    10651065
    1066     tr_bitfieldFree( tor->checkedPieces );
     1066    tr_bitfieldDestruct( &tor->checkedPieces );
    10671067
    10681068    tr_free( tor->downloadDir );
     
    16021602                          tr_piece_index_t   piece )
    16031603{
    1604     return tr_bitfieldHas( tor->checkedPieces, piece );
     1604    return tr_bitfieldHas( &tor->checkedPieces, piece );
    16051605}
    16061606
     
    16111611{
    16121612    if( isChecked )
    1613         tr_bitfieldAdd( tor->checkedPieces, piece );
     1613        tr_bitfieldAdd( &tor->checkedPieces, piece );
    16141614    else
    1615         tr_bitfieldRem( tor->checkedPieces, piece );
     1615        tr_bitfieldRem( &tor->checkedPieces, piece );
    16161616}
    16171617
     
    16261626
    16271627    if( isChecked )
    1628         tr_bitfieldAddRange ( tor->checkedPieces, begin, end );
     1628        tr_bitfieldAddRange ( &tor->checkedPieces, begin, end );
    16291629    else
    1630         tr_bitfieldRemRange ( tor->checkedPieces, begin, end );
     1630        tr_bitfieldRemRange ( &tor->checkedPieces, begin, end );
    16311631}
    16321632
     
    16511651tr_torrentUncheck( tr_torrent * tor )
    16521652{
    1653     tr_bitfieldRemRange ( tor->checkedPieces, 0, tor->info.pieceCount );
     1653    tr_bitfieldRemRange ( &tor->checkedPieces, 0, tor->info.pieceCount );
    16541654}
    16551655
     
    16571657tr_torrentCountUncheckedPieces( const tr_torrent * tor )
    16581658{
    1659     return tor->info.pieceCount - tr_bitfieldCountTrueBits(
    1660                tor->checkedPieces );
     1659    return tor->info.pieceCount - tr_bitfieldCountTrueBits( &tor->checkedPieces );
    16611660}
    16621661
Note: See TracChangeset for help on using the changeset viewer.