mirror of
https://github.com/minetest/minetest.git
synced 2025-01-03 11:57:30 +01:00
Fix core::array::reallocate when shrinking
This commit is contained in:
parent
f06383f78c
commit
7354cbe463
@ -59,8 +59,12 @@ public:
|
|||||||
{
|
{
|
||||||
size_t allocated = m_data.capacity();
|
size_t allocated = m_data.capacity();
|
||||||
if (new_size < allocated) {
|
if (new_size < allocated) {
|
||||||
if (canShrink)
|
if (canShrink) {
|
||||||
m_data.resize(new_size);
|
// since capacity != size don't accidentally make it bigger
|
||||||
|
if (m_data.size() > new_size)
|
||||||
|
m_data.resize(new_size);
|
||||||
|
m_data.shrink_to_fit();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
m_data.reserve(new_size);
|
m_data.reserve(new_size);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user