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()
|
~Vector()
|
||||||
{
|
{
|
||||||
if (m_data) {
|
if (m_data)
|
||||||
for(const T& item : *this)
|
{
|
||||||
{
|
for (const T& item : *this) { item.~T(); }
|
||||||
item.~T();
|
|
||||||
}
|
|
||||||
free_impl(m_data);
|
free_impl(m_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<void> try_reserve(usize capacity)
|
Result<void> try_reserve(usize capacity)
|
||||||
@ -115,10 +113,10 @@ template <typename T> class Vector
|
|||||||
|
|
||||||
T item = move(m_data[0]);
|
T item = move(m_data[0]);
|
||||||
|
|
||||||
memmove(m_data, m_data + 1, m_size - 1);
|
|
||||||
|
|
||||||
m_size--;
|
m_size--;
|
||||||
|
|
||||||
|
memmove(m_data, m_data + 1, m_size * sizeof(T));
|
||||||
|
|
||||||
return move(item);
|
return move(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user