1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

fix some memory issues.

This commit is contained in:
Charles Kerr 2007-10-01 04:12:24 +00:00
parent 0888fe4f68
commit 56738f065c
4 changed files with 7 additions and 50 deletions

View file

@ -171,7 +171,7 @@ tr_peerIoFree( tr_peerIo * c )
c->canRead = NULL;
c->didWrite = NULL;
c->gotError = NULL;
tr_bufferevent_free( c->handle, c->bufev );
bufferevent_free( c->bufev );
tr_netClose( c->socket );
tr_rcClose( c->rateToClient );

View file

@ -1086,16 +1086,15 @@ tr_peerMgrGetPeers( tr_peerMgr * manager,
tr_pex ** setme_pex )
{
const Torrent * t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
int i, peerCount;
const int isLocked = torrentIsLocked( t );
const tr_peer ** peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &peerCount );
tr_pex * pex = tr_new( tr_pex, peerCount );
tr_pex * walk = pex;
int i, peerCount;
const tr_peer ** peers;
tr_pex * pex;
tr_pex * walk;
if( !isLocked )
torrentLock( (Torrent*)t );
t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &peerCount );
pex = walk = tr_new( tr_pex, peerCount );
@ -1532,6 +1531,8 @@ getWeakConnections( Torrent * t, int * setmeSize )
const double throughput = (2*tr_peerIoGetRateToPeer( peer->io ))
+ tr_peerIoGetRateToClient( peer->io );
assert( atom != NULL );
/* if we're both seeds, give a little bit of time for
* a mutual pex -- peer-msgs initiates a pex exchange
* on startup -- and then disconnect */

View file

@ -66,7 +66,6 @@ enum mode
TR_EV_EVHTTP_MAKE_REQUEST,
TR_EV_BUFFEREVENT_SET,
TR_EV_BUFFEREVENT_WRITE,
TR_EV_BUFFEREVENT_FREE,
TR_EV_TIMER_ADD,
TR_EV_TIMER_DEL,
TR_EV_EXEC
@ -150,10 +149,6 @@ pumpList( int i UNUSED, short s UNUSED, void * veh )
tr_free( cmd->buf );
break;
case TR_EV_BUFFEREVENT_FREE:
bufferevent_free( cmd->bufev );
break;
case TR_EV_EXEC:
(cmd->func)( cmd->user_data );
break;
@ -417,39 +412,3 @@ tr_runInEventThread( struct tr_handle * handle,
pushList( handle->events, cmd );
}
}
/**
***
**/
static int
bufCompareFunc( const void * va, const void * vb )
{
const struct tr_event_command * a = va;
const struct bufferevent * b = vb;
return a->bufev == b ? 0 : 1;
}
void
tr_bufferevent_free( struct tr_handle * handle,
struct bufferevent * bufev )
{
void * v;
tr_event_handle * eh = handle->events;
/* purge pending commands from the list */
tr_lockLock( eh->lock );
while(( v = tr_list_remove( &eh->commands, bufev, bufCompareFunc ) ))
tr_free( v );
tr_lockUnlock( eh->lock );
if( tr_amInThread( handle->events->thread ) )
bufferevent_free( bufev );
else {
struct tr_event_command * cmd = tr_new0( struct tr_event_command, 1 );
cmd->mode = TR_EV_BUFFEREVENT_FREE;
cmd->bufev = bufev;
pushList( handle->events, cmd );
}
}

View file

@ -41,9 +41,6 @@ void tr_bufferevent_write( struct tr_handle * tr_handle,
const void * buf,
size_t buflen );
void tr_bufferevent_free( struct tr_handle * handle,
struct bufferevent * bufev );
void tr_setBufferEventMode( struct tr_handle * tr_handle,
struct bufferevent * bufferEvent,