Changeset 10920
- Timestamp:
- Jul 1, 2010, 3:14:35 PM (13 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/blocklist.c
r10858 r10920 80 80 blocklistLoad( tr_blocklist * b ) 81 81 { 82 int fd; 83 struct stat st; 82 int fd; 83 size_t byteCount; 84 struct stat st; 84 85 const char * err_fmt = _( "Couldn't read \"%1$s\": %2$s" ); 85 86 … … 96 97 } 97 98 98 b->rules = mmap( NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0 ); 99 byteCount = (size_t) st.st_size; 100 b->rules = mmap( NULL, byteCount, PROT_READ, MAP_PRIVATE, fd, 0 ); 99 101 if( !b->rules ) 100 102 { … … 104 106 } 105 107 106 b->byteCount = st.st_size;107 b->ruleCount = st.st_size / sizeof( struct tr_ip_range );108 108 b->fd = fd; 109 b->byteCount = byteCount; 110 b->ruleCount = byteCount / sizeof( struct tr_ip_range ); 109 111 110 112 { … … 146 148 147 149 tr_blocklist * 148 _tr_blocklistNew( const char * filename, 149 int isEnabled ) 150 _tr_blocklistNew( const char * filename, tr_bool isEnabled ) 150 151 { 151 152 tr_blocklist * b; -
trunk/libtransmission/blocklist.h
r9868 r10920 22 22 23 23 tr_blocklist* _tr_blocklistNew ( const char * filename, 24 intisEnabled );24 tr_bool isEnabled ); 25 25 26 26 int _tr_blocklistExists ( const tr_blocklist * b ); -
trunk/libtransmission/makemeta.c
r10781 r10920 89 89 } 90 90 91 static int91 static uint32_t 92 92 bestPieceSize( uint64_t totalSize ) 93 93 { 94 const uint 64_t GiB = 1073741824;95 const uint 64_t MiB = 1048576;96 const uint 64_t KiB = 1024;94 const uint32_t GiB = 1073741824; 95 const uint32_t MiB = 1048576; 96 const uint32_t KiB = 1024; 97 97 98 98 if( totalSize >= ( 2 * GiB ) ) return 2 * MiB; … … 227 227 while( totalRemain ) 228 228 { 229 uint8_t * bufptr = buf; 230 const uint64_t thisPieceSize = 231 MIN( (uint32_t)b->pieceSize, totalRemain ); 232 uint64_t pieceRemain = thisPieceSize; 229 uint8_t * bufptr = buf; 230 const uint32_t thisPieceSize = (uint32_t) MIN( b->pieceSize, totalRemain ); 231 uint32_t leftInPiece = thisPieceSize; 233 232 234 233 assert( b->pieceIndex < b->pieceCount ); 235 234 236 while( pieceRemain)235 while( leftInPiece ) 237 236 { 238 const uint64_t n_this_pass = 239 MIN( ( b->files[fileIndex].size - off ), pieceRemain ); 237 const size_t n_this_pass = (size_t) MIN( ( b->files[fileIndex].size - off ), leftInPiece ); 240 238 read( fd, bufptr, n_this_pass ); 241 239 bufptr += n_this_pass; 242 240 off += n_this_pass; 243 pieceRemain-= n_this_pass;241 leftInPiece -= n_this_pass; 244 242 if( off == b->files[fileIndex].size ) 245 243 { … … 266 264 267 265 assert( bufptr - buf == (int)thisPieceSize ); 268 assert( pieceRemain== 0 );266 assert( leftInPiece == 0 ); 269 267 tr_sha1( walk, buf, thisPieceSize, NULL ); 270 268 walk += SHA_DIGEST_LENGTH;
Note: See TracChangeset
for help on using the changeset viewer.