OS
v1.7.5
Documentation
|
A Memory Pool object. More...
#include <memory.hpp>
Public Member Functions | |
pool (void *pArea, const size_t pSize) noexcept | |
Initializes a memory pool instance. | |
bool | setup (void *pArea, const size_t pSize) noexcept |
Initializes a memory pool instance. This function should be called once before any heap memory request. | |
void | free (void *ptr) noexcept |
Deallocates the space previously allocated by mem::pool::alloc(). Deallocation will be performed in the selected memory pool. If ptr is a nullptr pointer, the function does nothing. The behavior is undefined if selected memory pool has not been initialized. The behavior is undefined if the value of ptr does not equal a value returned earlier by mem::pool::alloc(). The behavior is undefined if the memory area referred to by ptr has already been deallocated, that is, mem::pool::free() has already been called with ptr as the argument and no calls to mem::pool::alloc() resulted in a pointer equal to ptr afterwards. The behavior is undefined if after mem::pool::free() returns, an access is made through the pointer ptr. | |
void * | alloc (size_t pSize) noexcept |
Allocate a block of memory that is pSize bytes large. If the requested memory can be allocated, a pointer is returned to the beginning of the memory block. | |
size_t | getFreeSize (void) const noexcept |
Returns the total amount of heap space that remains unallocated for the memory pool. | |
A Memory Pool object.
A memory pool its a special resource that allows memory blocks to be dynamically allocated from a user-designated memory region. Instead of typical pools with fixed-size block allocation, the pools in QuarkTS++ can be of any size, thereby the user is responsible for selecting the appropriate memory pool to allocate data with the same size.
|
inlinenoexcept |
Initializes a memory pool instance.
[in] | pArea | A pointer to a memory block uint8_t statically allocated to act as Heap of the memory pool. The size of this block should match the pSize argument. |
[in] | pSize | The size of the memory block pointed by pArea |
|
noexcept |
Allocate a block of memory that is pSize bytes large. If the requested memory can be allocated, a pointer is returned to the beginning of the memory block.
[in] | pSize | Size of the memory block in bytes. |
nullptr
pointer is returned.
|
noexcept |
Deallocates the space previously allocated by mem::pool::alloc(). Deallocation will be performed in the selected memory pool. If ptr is a nullptr
pointer, the function does nothing. The behavior is undefined if selected memory pool has not been initialized. The behavior is undefined if the value of ptr does not equal a value returned earlier by mem::pool::alloc(). The behavior is undefined if the memory area referred to by ptr has already been deallocated, that is, mem::pool::free() has already been called with ptr as the argument and no calls to mem::pool::alloc() resulted in a pointer equal to ptr afterwards. The behavior is undefined if after mem::pool::free() returns, an access is made through the pointer ptr.
[in] | ptr | to the memory to deallocate |
|
noexcept |
Returns the total amount of heap space that remains unallocated for the memory pool.
|
noexcept |
Initializes a memory pool instance. This function should be called once before any heap memory request.
[in] | pArea | A pointer to a memory block uint8_t statically allocated to act as Heap of the memory pool. The size of this block should match the pSize argument. |
[in] | pSize | The size of the memory block pointed by pArea |
true
on success, otherwise, returns false
.