[ox/std] Fix Vector::expandCap to deallocate the correct amount of memory
This commit is contained in:
parent
b517cf6858
commit
4e2d7ea9dd
5
deps/ox/src/ox/std/vector.hpp
vendored
5
deps/ox/src/ox/std/vector.hpp
vendored
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user