Vector: Copy the right amount in try_dequeue()

I always forget to multiply by sizeof(T)...
This commit is contained in:
apio 2023-04-08 14:46:58 +02:00
parent 3da1849c99
commit 0f8a46ab67
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -65,13 +65,11 @@ template <typename T> class Vector
~Vector()
{
if (m_data) {
for(const T& item : *this)
{
item.~T();
}
if (m_data)
{
for (const T& item : *this) { item.~T(); }
free_impl(m_data);
}
}
}
Result<void> try_reserve(usize capacity)
@ -115,10 +113,10 @@ template <typename T> class Vector
T item = move(m_data[0]);
memmove(m_data, m_data + 1, m_size - 1);
m_size--;
memmove(m_data, m_data + 1, m_size * sizeof(T));
return move(item);
}