Changeset 2143


Ignore:
Timestamp:
Jun 18, 2007, 1:04:22 AM (15 years ago)
Author:
charles
Message:
  • fix 'piece size is always 1MB on 32 bit machines' bug.
  • fix label typo in gtk+ client
Location:
branches/file_selection
Files:
3 edited

Legend:

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

    r2138 r2143  
    218218    g_snprintf( buf, sizeof(buf), "<i>%lu %s @ %s</i>",
    219219                pieceCount,
    220                 ngettext("piece", "pieces", fileCount),
     220                ngettext("piece", "pieces", pieceCount),
    221221                pch );
    222222    gtk_label_set_markup ( GTK_LABEL(ui->pieces_lb), buf );
  • branches/file_selection/libtransmission/makemeta.c

    r2138 r2143  
    9494#define GiB 1073741824ul
    9595
    96 static size_t
    97 bestPieceSize( size_t totalSize )
     96static int
     97bestPieceSize( uint64_t totalSize )
    9898{
    9999    /* almost always best to have a piee size of 512 or 256 kb.
     
    124124tr_metaInfoBuilderCreate( tr_handle_t * handle, const char * topFile )
    125125{
    126     size_t i;
     126    int i;
    127127    struct FileList * files;
    128128    const struct FileList * walk;
     
    153153        ++ret->fileCount;
    154154    ret->files = calloc( ret->fileCount, sizeof(char*) );
    155     ret->fileLengths = calloc( ret->fileCount, sizeof(size_t) );
     155    ret->fileLengths = calloc( ret->fileCount, sizeof(uint64_t) );
    156156
    157157    for( i=0, walk=files; walk!=NULL; walk=walk->next, ++i )
     
    167167   
    168168    ret->pieceSize = bestPieceSize( ret->totalSize );
    169     ret->pieceCount = ret->totalSize / ret->pieceSize;
     169    ret->pieceCount = (int)( ret->totalSize / ret->pieceSize);
    170170    if( ret->totalSize % ret->pieceSize )
    171171        ++ret->pieceCount;
     
    179179    if( builder != NULL )
    180180    {
    181         size_t i;
     181        int i;
    182182        for( i=0; i<builder->fileCount; ++i )
    183183            tr_free( builder->files[i] );
     
    199199getHashInfo ( tr_metainfo_builder_t * b )
    200200{
    201     size_t off = 0;
    202     size_t fileIndex = 0;
     201    int fileIndex = 0;
    203202    uint8_t *ret = (uint8_t*) malloc ( SHA_DIGEST_LENGTH * b->pieceCount );
    204203    uint8_t *walk = ret;
    205204    uint8_t *buf = malloc( b->pieceSize );
    206     size_t totalRemain;
     205    uint64_t totalRemain;
     206    uint64_t off = 0;
    207207    FILE * fp;
    208208
     
    213213    {
    214214        uint8_t *bufptr = buf;
    215         const size_t thisPieceSize = MIN( b->pieceSize, totalRemain );
    216         size_t pieceRemain = thisPieceSize;
     215        const uint64_t thisPieceSize = MIN( (uint32_t)b->pieceSize, totalRemain );
     216        uint64_t pieceRemain = thisPieceSize;
    217217
    218218        assert( b->pieceIndex < b->pieceCount );
     
    220220        while( pieceRemain )
    221221        {
    222             const size_t n_this_pass = MIN( (b->fileLengths[fileIndex] - off), pieceRemain );
     222            const uint64_t n_this_pass = MIN( (b->fileLengths[fileIndex] - off), pieceRemain );
    223223            fread( bufptr, 1, n_this_pass, fp );
    224224            bufptr += n_this_pass;
     
    303303               const tr_metainfo_builder_t  * builder )
    304304{
    305     size_t i = 0;
     305    int i = 0;
    306306
    307307    tr_bencListReserve( list, builder->fileCount );
  • branches/file_selection/libtransmission/makemeta.h

    r2132 r2143  
    2121    char * top;
    2222    char ** files;
    23     size_t * fileLengths;
    24     size_t totalSize;
    25     size_t fileCount;
    26     size_t pieceSize;
    27     size_t pieceCount;
     23    uint64_t * fileLengths;
     24    uint64_t totalSize;
     25    int fileCount;
     26    int pieceSize;
     27    int pieceCount;
    2828    int isSingleFile;
    2929    tr_handle_t * handle;
     
    4747    **/
    4848
    49     size_t pieceIndex;
     49    int pieceIndex;
    5050    int abortFlag;
    5151    int isDone;
Note: See TracChangeset for help on using the changeset viewer.