Changeset 2114


Ignore:
Timestamp:
Jun 17, 2007, 4:10:26 AM (15 years ago)
Author:
charles
Message:
  • fix memory leaks in makemeta
  • faster hashing of files
  • more gui improvements in gtk torrent creator
Location:
branches/file_selection
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/file_selection/gtk/make-meta-ui.c

    r2112 r2114  
    4949}
    5050MakeMetaUI;
     51
     52static void
     53freeMetaUI( gpointer p )
     54{
     55    MakeMetaUI * ui = (MakeMetaUI *) p;
     56    tr_metaInfoBuilderFree( ui->builder );
     57    memset( ui, ~0, sizeof(MakeMetaUI) );
     58    g_free( ui );
     59}
    5160
    5261static void
     
    216225                                     NULL );
    217226    g_signal_connect( d, "response", G_CALLBACK(response_cb), ui );
    218     g_object_set_data_full( G_OBJECT(d), "ui", ui, g_free );
     227    g_object_set_data_full( G_OBJECT(d), "ui", ui, freeMetaUI );
    219228    ui->dialog = d;
    220229
  • branches/file_selection/libtransmission/makemeta.c

    r2112 r2114  
    195195    for( i=0; i<builder->fileCount; ++i )
    196196        tr_free( builder->files[i] );
     197    tr_free( builder->files );
     198    tr_free( builder->fileLengths );
    197199    tr_free( builder->top );
    198200    tr_free( builder->comment );
     
    215217    uint8_t *buf = malloc( b->pieceSize );
    216218    size_t totalRemain;
     219    FILE * fp;
    217220
    218221    b->pieceIndex = 0;
    219222    totalRemain = b->totalSize;
     223    fp = fopen( b->files[fileIndex], "rb" );
    220224    while ( totalRemain )
    221225    {
     
    228232        while( pieceRemain )
    229233        {
    230             FILE * fp = fopen( b->files[fileIndex], "rb" );
    231234            const size_t n_this_pass = MIN( (b->fileLengths[fileIndex] - off), pieceRemain );
    232             if( off )
    233                 fseek( fp, off, SEEK_SET );
    234235            fread( bufptr, 1, n_this_pass, fp );
    235236            bufptr += n_this_pass;
    236237            off += n_this_pass;
    237238            pieceRemain -= n_this_pass;
    238             fclose( fp );
    239 
    240239            if( off == b->fileLengths[fileIndex] ) {
    241240                off = 0;
    242                 ++fileIndex;
     241                fclose( fp );
     242                fp = NULL;
     243                if( ++fileIndex < b->fileCount ) {
     244                    fp = fopen( b->files[fileIndex], "rb" );
     245                }
    243246            }
    244247        }
     
    259262    assert( b->abortFlag || (walk-ret == (int)(SHA_DIGEST_LENGTH*b->pieceCount)) );
    260263    assert( b->abortFlag || !totalRemain );
     264    assert( fp == NULL );
    261265
    262266    free( buf );
Note: See TracChangeset for help on using the changeset viewer.