Central heap class whose use is paired with CachedHeap
. It is used to implement nmalloc
.
More...
#include "nn/nlib/heap/CentralHeap.h"
|
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...
|
|
errno_t | Free (void *p) noexcept |
| Frees memory. More...
|
|
bool | IsClean () noexcept |
| Checks whether the current heap status is the same as the status immediately after initialization, including metadata. More...
|
|
void | CalcHeapHash (HeapHash *hash) noexcept |
| For more information, see nmalloc_heaphash . More...
|
|
void | DumpEx (NMallocDumpMode mode, nlib_fd fd) const noexcept |
| For details, see nmalloc_dumpex2 . More...
|
|
void | DumpEx (NMallocDumpMode mode) const noexcept |
| For more information, see nmalloc_dumpex . More...
|
|
void | Dump () const noexcept |
| Runs DumpEx(NMALLOC_DUMP_BASIC, 1) .
|
|
errno_t | WalkAllocatedPtrs (nmalloc_heapwalk_callback func, void *user_ptr) noexcept |
| For more information, see nmalloc_walk_allocated_ptrs .
|
|
|
| CentralHeap () noexcept |
| Instantiates the object with default parameters (default constructor).
|
|
| ~CentralHeap () noexcept |
| Destructor.
|
|
|
errno_t | Initialize (void *start, size_t size, uint32_t heap_option) noexcept |
| Initializes the heap. More...
|
|
void | Finalize () noexcept |
| Finalizes use of the heap and changes the object's status to what it was prior to initialization.
|
|
bool | MakeCache (CachedHeap *ptr) noexcept |
| Initializes CachedHeap and associates it with this CentralHeap . More...
|
|
|
static const size_t | kPageSize |
| Page size of the heap (not related to the operating system page size).
|
|
Central heap class whose use is paired with CachedHeap
. It is used to implement nmalloc
.
- Description
- It can be used to create
CachedHeap
instances (thread-specific heaps). CachedHeap
allocates memory from and returns memory to the central heap. Memory allocation and freeing by user applications are generally performed using CachedHeap
. Memory can also be allocated directly from the CentralHeap
, however, this decreases efficiency.
Definition at line 18 of file CentralHeap.h.
nn::nlib::heap::CentralHeap::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 30 of file CentralHeap.h.
nn::nlib::heap::CentralHeap::Alloc |
( |
size_t |
n, |
|
|
size_t |
algn |
|
) |
| |
|
noexcept |
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.
- The alignment must be a power of two.
nn::nlib::heap::CentralHeap::CalcHeapHash |
( |
HeapHash * |
hash | ) |
|
|
noexcept |
For more information, see nmalloc_heaphash
.
- Parameters
-
[out] | hash | Specifies the pointer where the hash values are stored. |
For details, see nmalloc_dumpex2
.
- Parameters
-
[in] | mode | Specifies the display options. |
[in] | fd | Specifies the file descriptor to display. Specifying 1 indicates standard output. |
For more information, see nmalloc_dumpex
.
- Parameters
-
[in] | mode | Specifies the display options. |
Definition at line 38 of file CentralHeap.h.
nn::nlib::heap::CentralHeap::Free |
( |
void * |
p | ) |
|
|
noexcept |
Frees memory.
- Parameters
-
[in] | p | Specifies a pointer to the memory block to free. |
- Returns
- Returns
0
on success. Any nonzero value indicates that an error has occurred (for example, the pointer wasn't in the heap).
nn::nlib::heap::CentralHeap::Initialize |
( |
void * |
start, |
|
|
size_t |
size, |
|
|
uint32_t |
heap_option |
|
) |
| |
|
noexcept |
Initializes the heap.
- Parameters
-
[in] | start | Specifies a pointer to the beginning of the heap. |
[in] | size | Specifies the size of the heap. It must be a multiple of kPageSize . |
[in] | heap_option | Specifies the heap-instantiation options. See NMallocSettings::heap_option . |
- Returns
- 0 Indicates that initialization was successful. Any other return value indicates failure.
- Description
- If a start is not aligned to
kPageSize
, the region is truncated to the memory boundary before use.
nn::nlib::heap::CentralHeap::IsClean |
( |
| ) |
|
|
noexcept |
Checks whether the current heap status is the same as the status immediately after initialization, including metadata.
- Returns
- Returns
true
if the same as the heap status immediately following initialization.
- Description
- For more information, see
nmalloc_isclean
.
nn::nlib::heap::CentralHeap::MakeCache |
( |
CachedHeap * |
ptr | ) |
|
|
noexcept |
Initializes CachedHeap
and associates it with this CentralHeap
.
- Parameters
-
[out] | ptr | Specifies a pointer to the CachedHeap object to initialize. |
- Returns
- Returns
true
on success.
- Description
- When this function is called, the central heap allocates a cache region and associates itself with
CachedHeap
. Thereafter, memory can be allocated and freed using CachedHeap
.
The documentation for this class was generated from the following files: