fix uTP bug

This commit is contained in:
Arvid Norberg 2012-03-24 16:08:49 +00:00
parent 4d60adcaa9
commit c8f7b79e2b
2 changed files with 7 additions and 4 deletions

View File

@ -101,6 +101,9 @@ namespace libtorrent
private:
void** m_storage;
std::size_t m_capacity;
// this is the total number of elements that are occupied
// in the array
std::size_t m_size;
// This defines the first index that is part of the m_storage.

View File

@ -123,10 +123,10 @@ namespace libtorrent {
void* old_value = m_storage[idx & (m_capacity - 1)];
m_storage[idx & (m_capacity - 1)] = value;
if (m_size++ == 0)
{
m_first = idx;
}
if (m_size == 0) m_first = idx;
// if we're just replacing an old value, the number
// of elements in the buffer doesn't actually increase
if (old_value == 0) ++m_size;
TORRENT_ASSERT_VAL(m_first <= 0xffff, m_first);
return old_value;