[ox/std] Fix Vector::expandCap to deallocate the correct amount of memory

This commit is contained in:
Gary Talent 2022-02-19 16:42:21 -06:00
parent b517cf6858
commit 4e2d7ea9dd

View File

@ -633,7 +633,8 @@ constexpr Error Vector<T, SmallVectorSize>::unordered_erase(std::size_t pos) {
template<typename T, std::size_t SmallVectorSize>
constexpr void Vector<T, SmallVectorSize>::expandCap(std::size_t cap) {
auto oldItems = m_items;
const auto oldItems = m_items;
const auto oldCap = m_cap;
m_cap = cap;
this->allocate(&m_items, cap);
if (oldItems) { // move over old items
@ -641,7 +642,7 @@ constexpr void Vector<T, SmallVectorSize>::expandCap(std::size_t cap) {
for (std::size_t i = 0; i < itRange; ++i) {
new (&m_items[i]) T(std::move(oldItems[i]));
}
this->deallocate(oldItems, m_cap);
this->deallocate(oldItems, oldCap);
}
}