mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 14:41:50 +00:00
common canvas: return FailedAllocation if it really failed at memory allocation.
This fixes SwCanvasBase Reservation Unit Test.
This commit is contained in:
parent
ce6348a504
commit
f0ecc670ef
2 changed files with 4 additions and 2 deletions
|
@ -43,12 +43,14 @@ struct Array
|
|||
data[count++] = element;
|
||||
}
|
||||
|
||||
void reserve(uint32_t size)
|
||||
bool reserve(uint32_t size)
|
||||
{
|
||||
if (size > reserved) {
|
||||
reserved = size;
|
||||
data = static_cast<T*>(realloc(data, sizeof(T) * reserved));
|
||||
if (!data) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void pop()
|
||||
|
|
|
@ -38,7 +38,7 @@ Canvas::~Canvas()
|
|||
|
||||
Result Canvas::reserve(uint32_t n) noexcept
|
||||
{
|
||||
pImpl->paints.reserve(n);
|
||||
if (!pImpl->paints.reserve(n)) return Result::FailedAllocation;
|
||||
return Result::Success;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue