Changeset 2184


Ignore:
Timestamp:
Jun 22, 2007, 4:30:39 AM (15 years ago)
Author:
charles
Message:

misc cleanup.. ansification; fix my own typos, etc...

Location:
trunk/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/makemeta.c

    r2165 r2184  
    143143        ++ret->fileCount;
    144144
    145     ret->files = tr_calloc( ret->fileCount, sizeof(tr_metainfo_builder_file_t) );
     145    ret->files = tr_calloc(ret->fileCount, sizeof(tr_metainfo_builder_file_t));
    146146
    147147    for( i=0, walk=files; walk!=NULL; ++i )
     
    207207    {
    208208        uint8_t *bufptr = buf;
    209         const uint64_t thisPieceSize = MIN( (uint32_t)b->pieceSize, totalRemain );
     209        const uint64_t thisPieceSize =
     210            MIN( (uint32_t)b->pieceSize, totalRemain );
    210211        uint64_t pieceRemain = thisPieceSize;
    211212
     
    214215        while( pieceRemain )
    215216        {
    216             const uint64_t n_this_pass = MIN( (b->files[fileIndex].size - off), pieceRemain );
     217            const uint64_t n_this_pass =
     218                MIN( (b->files[fileIndex].size - off), pieceRemain );
    217219            fread( bufptr, 1, n_this_pass, fp );
    218220            bufptr += n_this_pass;
  • trunk/libtransmission/makemeta.h

    r2160 r2184  
    2222{
    2323    /**
    24     ***  These are set by tr_makeMetaInfo()
     24    ***  These are set by tr_makeMetaInfoBuilderCreate()
    2525    ***  and cleaned up by tr_metaInfoBuilderFree()
    2626    **/
  • trunk/libtransmission/peer.c

    r2177 r2184  
    5757/**
    5858 * We expend a fraction of our torrent's total upload speed
    59  * on on largesse by uniformly distributing free credit to
     59 * on largesse by uniformly distributing free credit to
    6060 * all of our peers.  This too helps prevent gridlock.
    6161 */
     
    603603
    604604        /* TODO: add some asserts to see if this bitfield is really necessary */
    605         tr_bitfield_t * blocksAlreadyRequested = tr_bitfieldNew( tor->blockCount );
     605        tr_bitfield_t * requestedBlocks = tr_bitfieldNew( tor->blockCount );
    606606        for( i=0; i<peer->inRequestCount; ++i) {
    607607            const tr_request_t * r = &peer->inRequests[i];
    608608            const int block = tr_block( r->index, r->begin );
    609             tr_bitfieldAdd( blocksAlreadyRequested, block );
     609            tr_bitfieldAdd( requestedBlocks, block );
    610610        }
    611611
     
    618618                : tr_cpMissingBlockInPiece ( tor->completion, piece );
    619619
    620             if( block>=0 && (endgame || !tr_bitfieldHas( blocksAlreadyRequested, block ) ) )
     620            if( block>=0 && (endgame || !tr_bitfieldHas( requestedBlocks, block ) ) )
    621621            {
    622                 tr_bitfieldAdd( blocksAlreadyRequested, block );
     622                tr_bitfieldAdd( requestedBlocks, block );
    623623                sendRequest( tor, peer, block );
    624624            }
     
    626626        }
    627627
    628         tr_bitfieldFree( blocksAlreadyRequested );
     628        tr_bitfieldFree( requestedBlocks );
    629629        free( pool );
    630630    }
     
    660660}
    661661
    662 /***********************************************************************
    663  * tr_peerProgress
    664  ***********************************************************************
    665  *
    666  **********************************************************************/
    667662float tr_peerProgress( const tr_peer_t * peer )
    668663{
     
    670665}
    671666
    672 /***********************************************************************
    673  * tr_peerPort
    674  ***********************************************************************
    675  * Returns peer's listening port in host byte order
    676  **********************************************************************/
    677667int tr_peerPort( const tr_peer_t * peer )
    678668{
     
    881871{
    882872    static time_t lastPulseTime = 0;
    883     const time_t now = time (NULL);
    884     tr_torrent_t * tor;
    885 
    886     if( lastPulseTime + SWIFT_REFRESH_INTERVAL_SEC > now )
    887         return;
    888     lastPulseTime = now;
    889 
    890     for( tor=h->torrentList; tor; tor=tor->next )
    891         tr_torrentSwiftPulse( tor );
    892 }
     873
     874    if( lastPulseTime + SWIFT_REFRESH_INTERVAL_SEC <= time( NULL ) )
     875    {
     876        tr_torrent_t * tor;
     877        for( tor=h->torrentList; tor; tor=tor->next )
     878            tr_torrentSwiftPulse( tor );
     879
     880        lastPulseTime = time( NULL );
     881    }
     882}
  • trunk/libtransmission/platform.c

    r2155 r2184  
    265265}
    266266
     267void tr_lockLock( tr_lock_t * l )
     268{
     269#ifdef SYS_BEOS
     270    acquire_sem( *l );
     271#else
     272    pthread_mutex_lock( l );
     273#endif
     274}
     275
     276void tr_lockUnlock( tr_lock_t * l )
     277{
     278#ifdef SYS_BEOS
     279    release_sem( *l );
     280#else
     281    pthread_mutex_unlock( l );
     282#endif
     283}
     284
    267285
    268286void tr_condInit( tr_cond_t * c )
  • trunk/libtransmission/platform.h

    r2154 r2184  
    4545tr_thread_t;
    4646
    47 /* only for debugging purposes */
    4847const char * tr_getHomeDirectory( void );
    49 
    5048const char * tr_getCacheDirectory( void );
    5149const char * tr_getTorrentsDirectory( void );
     
    6260void tr_lockInit     ( tr_lock_t * );
    6361void tr_lockClose    ( tr_lock_t * );
     62void tr_lockLock     ( tr_lock_t * );
     63void tr_lockUnlock   ( tr_lock_t * );
    6464
    65 static inline void tr_lockLock( tr_lock_t * l )
    66 {
    67 #ifdef SYS_BEOS
    68     acquire_sem( *l );
    69 #else
    70     pthread_mutex_lock( l );
    71 #endif
    72 }
    73 
    74 static inline void tr_lockUnlock( tr_lock_t * l )
    75 {
    76 #ifdef SYS_BEOS
    77     release_sem( *l );
    78 #else
    79     pthread_mutex_unlock( l );
    80 #endif
    81 }
    82 
    83 void tr_condInit( tr_cond_t * );
    84 void tr_condWait( tr_cond_t *, tr_lock_t * );
    85 void tr_condSignal( tr_cond_t * );
    86 void tr_condClose( tr_cond_t * );
     65void tr_condInit     ( tr_cond_t * );
     66void tr_condWait     ( tr_cond_t *, tr_lock_t * );
     67void tr_condSignal   ( tr_cond_t * );
     68void tr_condClose    ( tr_cond_t * );
    8769
    8870struct in_addr; /* forward declaration to calm gcc down */
Note: See TracChangeset for help on using the changeset viewer.