Describes an allocation on the heap. More...
#include <allocation.h>
Public Member Functions | |
| Allocation () | |
| Constructs a new zero-sized allocation. | |
| ~Allocation () | |
| Destroys the allocation. | |
| uint8_t * | GetBuffer () const |
| Gets the pointer to the start of the allocation. | |
| Bytes | GetLength () const |
| Gets the length of the allocation. | |
| Bytes | GetReservedLength () const |
| Gets the reserved length of the allocation. Calls to truncate may be ignored till the length exceeds the reserved length. | |
| bool | Truncate (Bytes length, bool npot=true) |
| Resize the underlying allocation to at least given number of bytes. | |
Static Public Member Functions | |
| static absl::StatusOr< uint64_t > | NextPowerOfTwoSize (uint64_t x) |
| Gets the next power of two size. | |
Describes an allocation on the heap.
Managing allocations through this utility makes it harder to
miss allocation failures.
Definition at line 23 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(), impeller::testing::TEST(), and impeller::interop::testing::TEST_P().
| Bytes impeller::Allocation::GetLength | ( | ) | const |
Gets the length of the allocation.
Definition at line 24 of file allocation.cc.
| 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 42 of file allocation.cc.
References x.
Referenced by impeller::testing::TEST().
| 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.
References FML_CHECK, and length.
Referenced by impeller::ProcTableGLES::GetProgramInfoLogString(), impeller::testing::TEST(), and impeller::interop::testing::TEST_P().