lazy_entry fix

This commit is contained in:
Arvid Norberg 2008-05-15 08:23:32 +00:00
parent 431dedda3e
commit 6ab19756a3
2 changed files with 11 additions and 0 deletions

View File

@ -179,6 +179,15 @@ namespace libtorrent
void clear();
// releases ownership of any memory allocated
void release()
{
m_data.start = 0;
m_size = 0;
m_capacity = 0;
m_type = none_t;
}
~lazy_entry()
{ clear(); }

View File

@ -187,6 +187,7 @@ namespace libtorrent
std::pair<char const*, lazy_entry>* tmp = new (std::nothrow) std::pair<char const*, lazy_entry>[capacity];
if (tmp == 0) return 0;
std::memcpy(tmp, m_data.dict, sizeof(std::pair<char const*, lazy_entry>) * m_size);
for (int i = 0; i < m_size; ++i) m_data.dict[i].second.release();
delete[] m_data.dict;
m_data.dict = tmp;
m_capacity = capacity;
@ -299,6 +300,7 @@ namespace libtorrent
lazy_entry* tmp = new (std::nothrow) lazy_entry[capacity];
if (tmp == 0) return 0;
std::memcpy(tmp, m_data.list, sizeof(lazy_entry) * m_size);
for (int i = 0; i < m_size; ++i) m_data.list[i].release();
delete[] m_data.list;
m_data.list = tmp;
m_capacity = capacity;