Region-based memory allocator thats owns memory of NDNph objects.
More...
#include <region.hpp>
Inherited by ndnph::StaticRegion< 2048 >, ndnph::StaticRegion< 512 >, ndnph::StaticRegion< 256 >, ndnph::DynamicRegion, and ndnph::StaticRegion< C >.
|
| Region (uint8_t *buf, size_t cap) |
|
uint8_t * | alloc (size_t size) |
| Allocate a buffer with no alignment requirement.
|
|
uint8_t * | allocA (size_t size) |
| Allocate a region aligned to multiple of sizeof(void*).
|
|
bool | free (const uint8_t *first, const uint8_t *last) |
| Deallocate (part of) last allocated buffer.
|
|
bool | free (const uint8_t *ptr, size_t size) |
|
template<typename T , typename... Arg> |
T * | make (Arg &&... arg) |
| Allocate and create an item, and return its pointer.
|
|
template<typename RefType , typename... Arg> |
RefType | create (Arg &&... arg) |
| Allocate and create an object, and return its reference.
|
|
void | reset () |
| Discard allocated items.
|
|
size_t | available () const |
| Compute remaining space for alloc().
|
|
size_t | availableA () const |
| Compute remaining space for allocA().
|
|
size_t | size () const |
| Compute utilized space.
|
|
Region-based memory allocator thats owns memory of NDNph objects.
◆ anonymous enum
◆ Region()
ndnph::Region::Region |
( |
uint8_t * |
buf, |
|
|
size_t |
cap |
|
) |
| |
|
inlineexplicit |
◆ alloc()
uint8_t * ndnph::Region::alloc |
( |
size_t |
size | ) |
|
|
inline |
Allocate a buffer with no alignment requirement.
◆ allocA()
uint8_t * ndnph::Region::allocA |
( |
size_t |
size | ) |
|
|
inline |
Allocate a region aligned to multiple of sizeof(void*).
◆ available()
size_t ndnph::Region::available |
( |
| ) |
const |
|
inline |
Compute remaining space for alloc().
◆ availableA()
size_t ndnph::Region::availableA |
( |
| ) |
const |
|
inline |
Compute remaining space for allocA().
◆ create()
template<typename RefType , typename... Arg>
RefType ndnph::Region::create |
( |
Arg &&... |
arg | ) |
|
|
inline |
Allocate and create an object, and return its reference.
- Template Parameters
-
RefType | a subclass of RefRegion<ObjType> , where ObjType is a subclass of InRegion . |
- Returns
- a reference to the created object.
- Warning
- If `!ref` is true on the returned reference, it indicates allocation failure. Using the reference in that case would cause segmentation fault.
◆ free() [1/2]
bool ndnph::Region::free |
( |
const uint8_t * |
first, |
|
|
const uint8_t * |
last |
|
) |
| |
|
inline |
Deallocate (part of) last allocated buffer.
- Return values
-
true | [first, last) is either front part of last buffer from alloc(), or back part of last buffer from allocA(), and has been freed. |
false | [first, last) cannot be freed. |
◆ free() [2/2]
bool ndnph::Region::free |
( |
const uint8_t * |
ptr, |
|
|
size_t |
size |
|
) |
| |
|
inline |
◆ getArray()
uint8_t * ndnph::Region::getArray |
( |
| ) |
|
|
inlineprotected |
◆ make()
template<typename T , typename... Arg>
T * ndnph::Region::make |
( |
Arg &&... |
arg | ) |
|
|
inline |
Allocate and create an item, and return its pointer.
◆ reset()
void ndnph::Region::reset |
( |
| ) |
|
|
inline |
Discard allocated items.
- Postcondition
- Allocated items are invalidated.
◆ size()
size_t ndnph::Region::size |
( |
| ) |
const |
|
inline |
◆ sizeofAligned()
template<typename T >
static constexpr T ndnph::Region::sizeofAligned |
( |
T |
size | ) |
|
|
inlinestaticconstexpr |
The documentation for this class was generated from the following file:
- /home/runner/work/esp8266ndn/NDNph/src/ndnph/core/region.hpp