Show
Ignore:
Timestamp:
08/25/10 03:14:19 (21 months ago)
Author:
rakshasa
Message:

* Some debugging tools added.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/libtorrent/src/data/chunk.cc

    r1105 r1172  
    114114 
    115115uint32_t 
    116 Chunk::incore_length(uint32_t pos) { 
    117   uint32_t lengthIncore = 0; 
     116Chunk::incore_length(uint32_t pos, uint32_t length) { 
     117  uint32_t result = 0; 
    118118  iterator itr = at_position(pos); 
    119119 
     
    121121    throw internal_error("Chunk::incore_length(...) at end()"); 
    122122 
    123   do { 
    124     uint32_t length = itr->incore_length(pos); 
    125  
    126     pos += length; 
    127     lengthIncore += length; 
     123  length = std::min(length, chunk_size() - pos); 
     124 
     125  do { 
     126    uint32_t incore_len = itr->incore_length(pos, length); 
     127 
     128    if (incore_len > length) 
     129      throw internal_error("Chunk::incore_length(...) incore_len > length."); 
     130 
     131    pos += incore_len; 
     132    length -= incore_len; 
     133    result += incore_len; 
    128134 
    129135  } while (pos == itr->position() + itr->size() && ++itr != end()); 
    130136 
    131   return lengthIncore; 
     137  return result; 
    132138} 
    133139