mirror of
https://github.com/thunderbrewhq/squall.git
synced 2026-02-04 00:49:08 +00:00
fix(array): correct implementation of TSFixedArray::ReallocAndClearData
This commit is contained in:
parent
7c9cda1b5b
commit
d590e2e94f
1 changed files with 13 additions and 4 deletions
|
|
@ -60,12 +60,21 @@ void TSFixedArray<T>::Clear() {
|
|||
|
||||
template <class T>
|
||||
void TSFixedArray<T>::ReallocAndClearData(uint32_t count) {
|
||||
// Destruct existing array elements
|
||||
for (uint32_t i = 0; i < this->Count(); i++) {
|
||||
auto element = &this->operator[](i);
|
||||
element->~T();
|
||||
}
|
||||
|
||||
// Reallocate if count changed
|
||||
if (count != this->m_count) {
|
||||
this->m_alloc = count;
|
||||
|
||||
if (this->m_data || count) {
|
||||
void* m = SMemReAlloc(this->m_data, sizeof(T) * count, this->MemFileName(), this->MemLineNo(), 0x0);
|
||||
this->m_data = static_cast<T*>(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue