iterator fixes (to avoid triggering safe iterator asserts)

This commit is contained in:
Arvid Norberg 2008-01-19 18:12:02 +00:00
parent 5ff6708b3d
commit 365b8c07c6
2 changed files with 8 additions and 4 deletions

View File

@ -222,11 +222,14 @@ struct bandwidth_manager
TORRENT_ASSERT(current_quota == m_current_quota); TORRENT_ASSERT(current_quota == m_current_quota);
typename queue_t::const_iterator j = m_queue.begin(); typename queue_t::const_iterator j = m_queue.begin();
if (j != m_queue.end())
{
++j; ++j;
for (typename queue_t::const_iterator i = m_queue.begin() for (typename queue_t::const_iterator i = m_queue.begin()
, end(m_queue.end()); i != end && j != end; ++i, ++j) , end(m_queue.end()); i != end && j != end; ++i, ++j)
TORRENT_ASSERT(i->priority >= j->priority); TORRENT_ASSERT(i->priority >= j->priority);
} }
}
#endif #endif
private: private:

View File

@ -2681,6 +2681,7 @@ namespace libtorrent
for (int c = 0; c < 2; ++c) for (int c = 0; c < 2; ++c)
{ {
queue_t::const_iterator j = m_bandwidth_queue[c].begin(); queue_t::const_iterator j = m_bandwidth_queue[c].begin();
if (j == m_bandwidth_queue[c].end()) continue;
++j; ++j;
for (queue_t::const_iterator i = m_bandwidth_queue[c].begin() for (queue_t::const_iterator i = m_bandwidth_queue[c].begin()
, end(m_bandwidth_queue[c].end()); i != end && j != end; ++i, ++j) , end(m_bandwidth_queue[c].end()); i != end && j != end; ++i, ++j)