BAN: memcpy only if we already have a buffer

This commit is contained in:
2023-01-13 00:15:40 +02:00
parent 75ee592fb5
commit c33c6c5785
3 changed files with 9 additions and 9 deletions

View File

@@ -211,7 +211,8 @@ namespace BAN
void* new_data = BAN::allocator(new_cap * sizeof(T));
if (new_data == nullptr)
return Error::FromString("Vector: Could not allocate memory");
memcpy(new_data, m_data, m_size * sizeof(T));
if (m_data)
memcpy(new_data, m_data, m_size * sizeof(T));
BAN::deallocator(m_data);
m_data = (T*)new_data;
m_capasity = new_cap;