From dcd05e45538a04b7b0d9ae0ff8cc01272a48fd33 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Mon, 9 Oct 2023 07:50:24 -0400 Subject: more memory works --- src/dynamic-array.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/dynamic-array.hpp') diff --git a/src/dynamic-array.hpp b/src/dynamic-array.hpp index 284ddcc..343f6c1 100644 --- a/src/dynamic-array.hpp +++ b/src/dynamic-array.hpp @@ -147,13 +147,13 @@ template inline void DynArray::Remove(std::size_t index) { assert(this->elementCount == 0 && "Invalid DynArray::Remove() - Contains no elements"); assert(index >= this->elementCount && "Invalid DynArray::Remove() - Out of bounds"); uint64_t moveCount = (this->elementCount - index - 1); - auto *tmp = Pke_New(this->elementSize * moveCount); + auto *tmp = Pke_New(sizeof(T) * moveCount); if IS_DESTRUCTIBLE(T) { reinterpret_cast(this->ptr + (index * sizeof(T))).~T(); } - memcpy(tmp, this->ptr + (this->elementSize * (index + 1)), this->elementSize * moveCount); - memcpy(this->ptr + (this->elementSize * index), tmp, this->elementSize * moveCount); - Pke_Delete(tmp, moveCount * this->elementSize); + memcpy(tmp, this->ptr + (sizeof(T) * (index + 1)), sizeof(T) * moveCount); + memcpy(this->ptr + (sizeof(T) * index), tmp, sizeof(T) * moveCount); + Pke_Delete(tmp, moveCount * sizeof(T)); this->elementCount -= 1; } -- cgit v1.2.3