mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Added GrowUninitialized
This commit is contained in:
parent
9c948d37ff
commit
350516fae3
1 changed files with 12 additions and 2 deletions
|
@ -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 <typename T, typename TAlloc = AllocatorCLib<T> >
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue