Vector: Copy the right amount in try_dequeue()
I always forget to multiply by sizeof(T)...
This commit is contained in:
parent
3da1849c99
commit
0f8a46ab67
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user