Allows memory to be allocated from both sides of the heap.
More...
#include "nn/nlib/heap/FrameHeap.h"
|
errno_t | Init (void *start, size_t size, DestructorHandler handler, uint32_t heap_option) noexcept |
| Initializes a frame heap. More...
|
|
void | FreeAll () noexcept |
| Frees all memory and restores the heap to its post-initialization state.
|
|
void | FreeTop () noexcept |
| Frees all memory regions that were allocated from top of the heap.
|
|
void | FreeBot () noexcept |
| Frees all memory regions that were allocated from bottom of the heap.
|
|
errno_t | ResizeTop (void *p, size_t from_size, size_t to_size) noexcept |
| Changes the size of the most recently allocated memory. More...
|
|
errno_t | Adjust (void **start, size_t *size) noexcept |
| Truncates the size of the heap up so that it stops after the regions that have been allocated so far. The function fails without truncating if memory has already been allocated from both sides. More...
|
|
State | SaveState () noexcept |
| Saves the current heap state. More...
|
|
void | RestoreState (State state) noexcept |
| Restores a saved heap state. More...
|
|
void * | Alloc (size_t n) noexcept |
| Allocates a memory block. More...
|
|
void * | Alloc (size_t n, size_t algn) noexcept |
| Allocates a memory block with a specific alignment. More...
|
|
void * | Alloc (size_t n, size_t algn, uint32_t alloc_option) noexcept |
| Allocates a memory block with a specific alignment and allocation options. More...
|
|
void | Dump () noexcept |
| Dumps the heap status.
|
|
Allows memory to be allocated from both sides of the heap.
Definition at line 16 of file FrameHeap.h.
§ AllocOption
Specifies which side of the heap to allocate from.
Enumerator |
---|
ALLOCOPTION_ALLOCHEAD | Allocates from the front of the heap.
|
ALLOCOPTION_ALLOCTAIL | Allocates from the end of the heap.
|
Definition at line 19 of file FrameHeap.h.
§ Adjust()
nn::nlib::heap::FrameHeap::Adjust |
( |
void ** |
start, |
|
|
size_t * |
size |
|
) |
| |
|
noexcept |
Truncates the size of the heap up so that it stops after the regions that have been allocated so far. The function fails without truncating if memory has already been allocated from both sides.
- Parameters
-
[in] | start | Specifies a pointer to the start of the region to remove from the heap. |
[in] | size | Specifies the size of the region to remove from the heap. |
- Returns
- Returns
0
on success. Any other value indicates failure.
§ Alloc() [1/3]
nn::nlib::heap::FrameHeap::Alloc |
( |
size_t |
n | ) |
|
|
inlinenoexcept |
Allocates a memory block.
- Parameters
-
[in] | n | Specifies the memory block size. |
- Returns
- Returns the pointer for the allocated memory.
NULL
if process fails.
Definition at line 59 of file FrameHeap.h.
§ Alloc() [2/3]
nn::nlib::heap::FrameHeap::Alloc |
( |
size_t |
n, |
|
|
size_t |
algn |
|
) |
| |
|
inlinenoexcept |
Allocates a memory block with a specific alignment.
- Parameters
-
[in] | n | Specifies the memory block size. |
[in] | algn | Specifies the alignment. |
- Returns
- Returns the pointer for the allocated memory.
NULL
if process fails.
Definition at line 60 of file FrameHeap.h.
§ Alloc() [3/3]
nn::nlib::heap::FrameHeap::Alloc |
( |
size_t |
n, |
|
|
size_t |
algn, |
|
|
uint32_t |
alloc_option |
|
) |
| |
|
noexcept |
Allocates a memory block with a specific alignment and allocation options.
- Parameters
-
[in] | n | Specifies the memory block size. |
[in] | algn | Specifies the alignment. |
[in] | alloc_option | Specifies options during allocation (value of type AllocOption ). |
- Returns
- Returns the pointer for the allocated memory.
NULL
if process fails.
§ Init()
nn::nlib::heap::FrameHeap::Init |
( |
void * |
start, |
|
|
size_t |
size, |
|
|
DestructorHandler |
handler, |
|
|
uint32_t |
heap_option |
|
) |
| |
|
noexcept |
Initializes a frame heap.
- Parameters
-
[in] | start | Specifies a pointer to the beginning of the heap. |
[in] | size | Specifies the size of the heap. |
[in] | handler | Specifies a pointer to the function that is called when the destructor runs. |
[in] | heap_option | This value is not used. |
- Returns
- Returns
0
if initialization succeeded, or any other value if initialization failed.
§ ResizeTop()
nn::nlib::heap::FrameHeap::ResizeTop |
( |
void * |
p, |
|
|
size_t |
from_size, |
|
|
size_t |
to_size |
|
) |
| |
|
noexcept |
Changes the size of the most recently allocated memory.
- Parameters
-
[in] | p | Specifies the pointer to the most recently allocated memory. |
[in] | from_size | Specifies the original size. |
[in] | to_size | Specifies the desired size. |
- Returns
- Returns
0
on success. Any other value indicates failure.
§ RestoreState()
nn::nlib::heap::FrameHeap::RestoreState |
( |
State |
state | ) |
|
|
inlinenoexcept |
Restores a saved heap state.
- Parameters
-
[in] | state | Specifies the state of the heap to be restored. |
Definition at line 58 of file FrameHeap.h.
§ SaveState()
nn::nlib::heap::FrameHeap::SaveState |
( |
| ) |
|
|
inlinenoexcept |
Saves the current heap state.
- Returns
- Saves the current memory allocation state of the heap.
Definition at line 57 of file FrameHeap.h.
The documentation for this class was generated from the following files: