Allocator that can be set for each instance of XmlStreamReader
and XmlStreamWriter
.
More...
#include "nn/nlib/exi/ExiAllocator.h"
Allocator that can be set for each instance of XmlStreamReader
and XmlStreamWriter
.
- Description
ExiAllocator
is a singleton, but ExiAllocatorEx
can create instances. By passing arguments to XmlStreamReader
and XmlStreamWriter
, different allocators can be used for each instance (even within the same thread).
- The same member functions are implemented as
ExiAllocator
. Sample usage is shown below.
al_writer.Initialize(g_WriterBuf, BUF_SIZE);
OutputStream* os = ....;
Definition at line 22 of file ExiAllocator.h.
nn::nlib::exi::ExiAllocatorEx::Alloc |
( |
size_t |
nbytes | ) |
|
|
noexcept |
Allocates nBytes of memory from the allocator.
- Parameters
-
[in] | nbytes | Memory size to allocate. |
- Returns
- Address of the allocated memory.
NULL
if process fails.
nn::nlib::exi::ExiAllocatorEx::Dealloc |
( |
void * |
p | ) |
|
|
noexcept |
Called when memory is deallocated.
- Parameters
-
[in] | p | Starting address of the memory to deallocate. |
nn::nlib::exi::ExiAllocatorEx::Finalize |
( |
| ) |
|
|
noexcept |
Finalizes allocator use.
- Returns
- Pointer to the memory block that was provided during initialization.
nn::nlib::exi::ExiAllocatorEx::GetPos |
( |
| ) |
|
|
noexcept |
Returns the amount of memory that has already been allocated.
- Returns
- Amount of memory that has already been allocated.
nn::nlib::exi::ExiAllocatorEx::Initialize |
( |
void * |
p, |
|
|
size_t |
size |
|
) |
| |
|
noexcept |
Initializes an allocator.
- Parameters
-
[in] | p | Pointer to the start of the memory block. |
[in] | size | Memory block size. |
- Returns
- Returns
true
on success.
- Description
- Allocates memory to an allocator and initializes it.
nn::nlib::exi::ExiAllocatorEx::IsOutOfMemory |
( |
| ) |
|
|
noexcept |
Checks whether the previous attempt at memory allocation failed.
- Returns
- Returns
true
if memory allocation failed.
nn::nlib::exi::ExiAllocatorEx::Realloc |
( |
void * |
ptr, |
|
|
size_t |
from_nbytes, |
|
|
size_t |
nbytes |
|
) |
| |
|
noexcept |
Sometimes called when expanding the amount of memory that has been allocated.
- Parameters
-
[in] | ptr | Starting address of the memory to expand. |
[in] | from_nbytes | Memory size allocated prior to expansion. |
[in] | nbytes | Memory size after expansion. |
- Returns
- Address of the allocated memory.
NULL
if process fails.
- Description
- Unlike with the standard C
realloc
function, pass this function the amount of memory currently allocated.
nn::nlib::exi::ExiAllocatorEx::Test |
( |
size_t |
nbytes | ) |
|
|
noexcept |
Tests whether nBytes of memory can be allocated.
- Parameters
-
[in] | nbytes | Memory size to attempt to allocate. |
- Returns
- Returns
false
if allocation is not possible.
- Description
- If it returns
false
, the subsequent call to IsOutOfMemory()
returns true
. Used to determine in advance whether Alloc()
will fail.
The documentation for this class was generated from the following files: