forked from Bananymous/banan-os
BAN: Queue and Vector now default initialize newly allocated elements
This commit is contained in:
parent
c35181a92f
commit
6ed542d6bf
|
@ -102,8 +102,9 @@ namespace BAN
|
||||||
memcpy(new_data, m_data, m_size * sizeof(T));
|
memcpy(new_data, m_data, m_size * sizeof(T));
|
||||||
BAN::deallocator(m_data);
|
BAN::deallocator(m_data);
|
||||||
m_data = (T*)new_data;
|
m_data = (T*)new_data;
|
||||||
|
for (size_type i = m_capacity; i < new_cap; i++)
|
||||||
|
m_data[i] = T();
|
||||||
m_capacity = new_cap;
|
m_capacity = new_cap;
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,6 +215,8 @@ namespace BAN
|
||||||
memcpy(new_data, m_data, m_size * sizeof(T));
|
memcpy(new_data, m_data, m_size * sizeof(T));
|
||||||
BAN::deallocator(m_data);
|
BAN::deallocator(m_data);
|
||||||
m_data = (T*)new_data;
|
m_data = (T*)new_data;
|
||||||
|
for (size_type i = m_capasity; i < new_cap; i++)
|
||||||
|
m_data[i] = T();
|
||||||
m_capasity = new_cap;
|
m_capasity = new_cap;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue