From 350516fae3111d4ed1edd114e53f45e78bb224cb Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sun, 13 Dec 2020 08:02:31 -0800 Subject: [PATCH] Added GrowUninitialized --- BeefySysLib/util/Array.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/BeefySysLib/util/Array.h b/BeefySysLib/util/Array.h index 8b350b9d..9a81ed8a 100644 --- a/BeefySysLib/util/Array.h +++ b/BeefySysLib/util/Array.h @@ -459,7 +459,7 @@ protected: void EnsureFree(intptr freeCount) { if (this->mSize + freeCount > this->mAllocSize) - SetBufferSize(std::max(this->mAllocSize + this->mAllocSize / 2 + 1, this->mSize + freeCount)); + SetBufferSize(BF_MAX(this->mAllocSize + this->mAllocSize / 2 + 1, this->mSize + freeCount)); } public: @@ -770,7 +770,7 @@ protected: void EnsureFree(intptr freeCount) { if (this->mSize + freeCount > this->mAllocSize) - SetBufferSize(std::max(this->mAllocSize + this->mAllocSize / 2 + 1, this->mSize + freeCount)); + SetBufferSize(BF_MAX(this->mAllocSize + this->mAllocSize / 2 + 1, this->mSize + freeCount)); } public: @@ -1054,6 +1054,16 @@ public: SetBufferSize(this->mAllocSize + this->mAllocSize / 2 + 1); this->mVals[this->mSize++] = val; } + + T* GrowUninitialized(int addSize) + { + if (this->mSize + addSize > this->mAllocSize) + EnsureFree(addSize); + this->mSize += (int_cosize)addSize; + if (addSize == 0) + return NULL; + return &this->mVals[this->mSize - addSize]; + } }; template >