Describes an allocation on the heap. More...
#include <allocation.h>
Public Member Functions | |
Allocation () | |
Constructs a new zero-sized allocation. More... | |
~Allocation () | |
Destroys the allocation. More... | |
uint8_t * | GetBuffer () const |
Gets the pointer to the start of the allocation. More... | |
Bytes | GetLength () const |
Gets the length of the allocation. More... | |
Bytes | GetReservedLength () const |
Gets the reserved length of the allocation. Calls to truncate may be ignored till the length exceeds the reserved length. More... | |
bool | Truncate (Bytes length, bool npot=true) |
Resize the underlying allocation to at least given number of bytes. More... | |
Static Public Member Functions | |
static uint32_t | NextPowerOfTwoSize (uint32_t x) |
Gets the next power of two size. More... | |
Describes an allocation on the heap.
Managing allocations through this utility makes it harder to miss allocation failures.
Definition at line 22 of file allocation.h.
|
default |
Constructs a new zero-sized allocation.
impeller::Allocation::~Allocation | ( | ) |
uint8_t * impeller::Allocation::GetBuffer | ( | ) | const |
Gets the pointer to the start of the allocation.
This pointer is only valid till the next call to `Truncate`.
Definition at line 20 of file allocation.cc.
Referenced by impeller::ProcTableGLES::GetProgramInfoLogString(), and impeller::interop::testing::TEST_P().
Bytes impeller::Allocation::GetLength | ( | ) | const |
Bytes impeller::Allocation::GetReservedLength | ( | ) | const |
Gets the reserved length of the allocation. Calls to truncate may be ignored till the length exceeds the reserved length.
Definition at line 28 of file allocation.cc.
|
static |
Gets the next power of two size.
[in] | x | The size. |
Definition at line 41 of file allocation.cc.
References x.
bool impeller::Allocation::Truncate | ( | Bytes | length, |
bool | npot = true |
||
) |
Resize the underlying allocation to at least given number of bytes.
In case of failure, false is returned and the underlying allocation remains unchanged.
GetBuffer
may become invalid at this point.[in] | length | The length. |
[in] | npot | Whether to round up the length to the next power of two. |
Definition at line 32 of file allocation.cc.
Referenced by impeller::ProcTableGLES::GetProgramInfoLogString(), and impeller::interop::testing::TEST_P().