Changeset 3247


Ignore:
Timestamp:
Oct 1, 2007, 4:12:24 AM (14 years ago)
Author:
charles
Message:

fix some memory issues.

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r3242 r3247  
    172172        c->didWrite = NULL;
    173173        c->gotError = NULL;
    174         tr_bufferevent_free( c->handle, c->bufev );
     174        bufferevent_free( c->bufev );
    175175        tr_netClose( c->socket );
    176176
  • trunk/libtransmission/peer-mgr.c

    r3245 r3247  
    10871087{
    10881088    const Torrent * t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
     1089    const int isLocked = torrentIsLocked( t );
    10891090    int i, peerCount;
    1090     const int isLocked = torrentIsLocked( t );
    1091     const tr_peer ** peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &peerCount );
    1092     tr_pex * pex = tr_new( tr_pex, peerCount );
    1093     tr_pex * walk = pex;
     1091    const tr_peer ** peers;
     1092    tr_pex * pex;
     1093    tr_pex * walk;
    10941094
    10951095    if( !isLocked )
    10961096        torrentLock( (Torrent*)t );
    10971097
    1098     t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
    10991098    peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &peerCount );
    11001099    pex = walk = tr_new( tr_pex, peerCount );
     
    15331532                                + tr_peerIoGetRateToClient( peer->io );
    15341533
     1534        assert( atom != NULL );
     1535
    15351536        /* if we're both seeds, give a little bit of time for
    15361537         * a mutual pex -- peer-msgs initiates a pex exchange
  • trunk/libtransmission/trevent.c

    r3217 r3247  
    6767    TR_EV_BUFFEREVENT_SET,
    6868    TR_EV_BUFFEREVENT_WRITE,
    69     TR_EV_BUFFEREVENT_FREE,
    7069    TR_EV_TIMER_ADD,
    7170    TR_EV_TIMER_DEL,
     
    149148                bufferevent_write( cmd->bufev, cmd->buf, cmd->buflen );
    150149                tr_free( cmd->buf );
    151                 break;
    152 
    153             case TR_EV_BUFFEREVENT_FREE:
    154                 bufferevent_free( cmd->bufev );
    155150                break;
    156151
     
    418413    }
    419414}
    420 
    421 
    422 /**
    423 ***
    424 **/
    425 
    426 static int
    427 bufCompareFunc( const void * va, const void * vb )
    428 {
    429     const struct tr_event_command * a = va;
    430     const struct bufferevent * b = vb;
    431     return a->bufev == b ? 0 : 1;
    432 }
    433 
    434 void
    435 tr_bufferevent_free( struct tr_handle   * handle,
    436                      struct bufferevent * bufev )
    437 {
    438     void * v;
    439     tr_event_handle * eh = handle->events;
    440 
    441     /* purge pending commands from the list */
    442     tr_lockLock( eh->lock );
    443     while(( v = tr_list_remove( &eh->commands, bufev, bufCompareFunc ) ))
    444         tr_free( v );
    445     tr_lockUnlock( eh->lock );
    446 
    447     if( tr_amInThread( handle->events->thread ) )
    448         bufferevent_free( bufev );
    449     else {
    450         struct tr_event_command * cmd = tr_new0( struct tr_event_command, 1 );
    451         cmd->mode = TR_EV_BUFFEREVENT_FREE;
    452         cmd->bufev = bufev;
    453         pushList( handle->events, cmd );
    454     }
    455 }
  • trunk/libtransmission/trevent.h

    r3105 r3247  
    4242                           size_t                buflen );
    4343
    44 void tr_bufferevent_free( struct tr_handle   * handle,
    45                           struct bufferevent * bufev );
    46 
    4744
    4845void tr_setBufferEventMode( struct tr_handle   * tr_handle,
Note: See TracChangeset for help on using the changeset viewer.