Changeset 5627


Ignore:
Timestamp:
Apr 15, 2008, 5:00:44 PM (14 years ago)
Author:
charles
Message:

more hacking on the bencoded resume files

Location:
trunk/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode.c

    r5620 r5627  
    500500}
    501501
    502 int
    503 tr_bencInitStrDupLen( tr_benc * val, const char * str, int len )
    504 {
    505     char * newStr = tr_strndup( str, len );
     502void
     503tr_bencInitRaw( tr_benc * val, const void * src, size_t byteCount )
     504{
     505    tr_bencInit( val, TYPE_STR );
     506    val->val.s.i = byteCount;
     507    val->val.s.s = tr_new( char, byteCount );
     508    val->val.s.nofree = 0;
     509    memcpy( val->val.s.s, src, byteCount );
     510}
     511
     512int
     513tr_bencInitStrDup( tr_benc * val, const char * str )
     514{
     515    char * newStr = tr_strdup( str );
    506516    if( newStr == NULL )
    507517        return 1;
     
    509519    _tr_bencInitStr( val, newStr, 0, 0 );
    510520    return 0;
    511 }
    512 
    513 int
    514 tr_bencInitStrDup( tr_benc * val, const char * str )
    515 {
    516     return tr_bencInitStrDupLen( val, str, -1 );
    517521}
    518522
  • trunk/libtransmission/bencode.h

    r5611 r5627  
    9292void   _tr_bencInitStr( tr_benc * val, char * str, int len, int nofree );
    9393int    tr_bencInitStrDup( tr_benc * val, const char * str );
     94void   tr_bencInitRaw( tr_benc * val, const void * src, size_t byteCount );
    9495int    tr_bencInitStrDupLen( tr_benc * val, const char * str, int len );
    9596void   tr_bencInitInt( tr_benc * val, int64_t num );
  • trunk/libtransmission/completion.c

    r5606 r5627  
    231231}
    232232
    233 const tr_bitfield * tr_cpBlockBitfield( const tr_completion * cp )
    234 {
    235     assert( cp != NULL );
     233const tr_bitfield *
     234tr_cpBlockBitfield( const tr_completion * cp )
     235{
     236    assert( cp );
     237    assert( cp->blockBitfield );
     238    assert( cp->blockBitfield->bits );
     239    assert( cp->blockBitfield->len );
    236240
    237241    return cp->blockBitfield;
     
    242246{
    243247    tr_block_index_t i;
     248
     249    assert( cp );
     250    assert( bitfield );
     251    assert( cp->blockBitfield );
     252    assert( cp->blockBitfield->len == bitfield->len );
    244253
    245254    if( !cp || !bitfield || ( bitfield->len != cp->blockBitfield->len ) )
  • trunk/libtransmission/resume.c

    r5623 r5627  
    6767                                          tor->info.hash, &pex );
    6868    if( count > 0 )
    69         tr_bencInitStrDupLen( tr_bencDictAdd( dict, KEY_PEERS ),
    70                               (const char*)pex, sizeof(tr_pex)*count );
     69        tr_bencInitRaw( tr_bencDictAdd( dict, KEY_PEERS ), pex, sizeof(tr_pex)*count );
    7170    tr_free( pex );
    7271}
     
    269268    bitfield = tr_cpBlockBitfield( tor->completion );
    270269    b = tr_bencDictAdd( p, KEY_PROGRESS_BITFIELD );
    271     tr_bencInitStrDupLen( b, (const char*)bitfield->bits, bitfield->len );
     270    tr_bencInitRaw( b, bitfield->bits, bitfield->len );
    272271
    273272    /* cleanup */
  • trunk/libtransmission/torrent.c

    r5621 r5627  
    992992    tr_globalLock( tor->handle );
    993993
     994    tor->isRunning = 0;
    994995    if( !tor->isDeleting )
    995996        tr_torrentSaveResume( tor );
    996     tor->isRunning = 0;
    997997    tr_runInEventThread( tor->handle, stopTorrent, tor );
    998998
Note: See TracChangeset for help on using the changeset viewer.