Too many elements were trimmed from the end of the lists
due to a wrong calculation of the last unused chunk length.
This commit is contained in:
King_DuckZ 2014-07-04 13:23:37 +02:00
parent 765e28849c
commit 9a8367c00c

View file

@ -136,9 +136,14 @@ namespace cloonel {
m_occupied[parTicket - 1] = false;
--m_usedCount;
auto lastNull = std::find(m_occupied.rbegin(), m_occupied.rend(), false);
if (m_occupied.rend() != lastNull) {
const std::size_t newSize = m_occupied.size() - static_cast<std::size_t>(lastNull - m_occupied.rbegin()) + 1;
std::size_t deleCount = 0;
for (auto itOcc = m_occupied.rbegin(), itOccEND = m_occupied.rend(); itOcc != itOccEND and not *itOcc; ++itOcc) {
++deleCount;
}
if (deleCount) {
assert(deleCount <= m_occupied.size());
const std::size_t newSize = m_occupied.size() - deleCount;
m_occupied.resize(newSize);
m_list.resize(newSize);
}