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

fix some memory issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 }
Note: See TracChangeset for help on using the changeset viewer.