Bugfix.
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:
parent
765e28849c
commit
9a8367c00c
1 changed files with 8 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue