4#include "include/types.hpp"
6#ifndef Q_BYTE_ALIGNMENT
7 #define Q_BYTE_ALIGNMENT ( 8 )
10#if ( ( Q_BYTE_ALIGNMENT != 1 ) && ( Q_BYTE_ALIGNMENT != 2 ) && ( Q_BYTE_ALIGNMENT != 4 ) && ( Q_BYTE_ALIGNMENT != 8 ) )
11 #error Q_BYTE_ALIGNMENT value not allowed, use only 1,2,4 or 8(default).
27 using address_t = size_t;
28 struct blockConnect_t {
29 blockConnect_t *next{
nullptr };
30 size_t blockSize{ 0U };
44 blockConnect_t *end{
nullptr };
46 uint8_t *poolMemory{
nullptr };
47 size_t poolMemSize{ 0U };
48 size_t freeBytesRemaining{ 0U };
49 void insertBlockIntoFreeList( blockConnect_t *xBlock )
noexcept;
50 void init(
void )
noexcept;
52 void operator=(
pool const& ) =
delete;
64 inline pool(
void *pArea,
const size_t pSize )
noexcept {
65 (void)
setup( pArea, pSize );
76 bool setup(
void *pArea,
const size_t pSize )
noexcept;
92 void free(
void *ptr )
noexcept;
103 void*
alloc(
size_t pSize )
noexcept;
116 #if ( Q_DEFAULT_HEAP_SIZE >= 64 )
117 void *
operator new(
size_t size);
118 void *
operator new[](
size_t size);
120 void operator delete(
void * ptr)
noexcept;
121 void operator delete[](
void * ptr)
noexcept;
123 void operator delete(
void* ptr,
void* place)
noexcept;
124 void operator delete[](
void* ptr,
void* place)
noexcept;
A Memory Pool object.
Definition memory.hpp:42
bool setup(void *pArea, const size_t pSize) noexcept
Initializes a memory pool instance. This function should be called once before any heap memory reques...
pool(void *pArea, const size_t pSize) noexcept
Initializes a memory pool instance.
Definition memory.hpp:64
void * alloc(size_t pSize) noexcept
Allocate a block of memory that is pSize bytes large. If the requested memory can be allocated,...
void free(void *ptr) noexcept
Deallocates the space previously allocated by mem::pool::alloc(). Deallocation will be performed in t...
size_t getFreeSize(void) const noexcept
Returns the total amount of heap space that remains unallocated for the memory pool.
OS/Kernel interfaces.
Definition bytebuffer.hpp:7