mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +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)
|
void EnsureFree(intptr freeCount)
|
||||||
{
|
{
|
||||||
if (this->mSize + freeCount > this->mAllocSize)
|
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:
|
public:
|
||||||
|
@ -770,7 +770,7 @@ protected:
|
||||||
void EnsureFree(intptr freeCount)
|
void EnsureFree(intptr freeCount)
|
||||||
{
|
{
|
||||||
if (this->mSize + freeCount > this->mAllocSize)
|
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:
|
public:
|
||||||
|
@ -1054,6 +1054,16 @@ public:
|
||||||
SetBufferSize(this->mAllocSize + this->mAllocSize / 2 + 1);
|
SetBufferSize(this->mAllocSize + this->mAllocSize / 2 + 1);
|
||||||
this->mVals[this->mSize++] = val;
|
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> >
|
template <typename T, typename TAlloc = AllocatorCLib<T> >
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue