Uniot Core
0.8.1
Loading...
Searching...
No Matches
uniot::GlobalBufferMemoryManager Class Reference

#include <GlobalBufferMemoryManager.h>

Static Public Member Functions

static void initialize ()
 Initialize the memory manager.
 
static void * allocate (size_t size)
 Allocate memory from the global buffer.
 
static void deallocate (void *ptr)
 Deallocate previously allocated memory.
 
static void * reallocate (void *ptr, size_t newSize)
 Resize allocated memory.
 
static size_t getTotalFreeMemory ()
 Get the total free memory available in the buffer.
 
static size_t getLargestFreeBlock ()
 Get the size of the largest available free block.
 

Member Function Documentation

◆ allocate()

void * uniot::GlobalBufferMemoryManager::allocate ( size_t size)
static

Allocate memory from the global buffer.

Parameters
sizeNumber of bytes to allocate
Return values
void*Pointer to the allocated memory block
nullptrIf allocation fails

◆ deallocate()

void uniot::GlobalBufferMemoryManager::deallocate ( void * ptr)
static

Deallocate previously allocated memory.

Returns the memory block to the free list, merging with adjacent free blocks when possible.

Parameters
ptrPointer to memory previously allocated with allocate()

◆ getLargestFreeBlock()

size_t uniot::GlobalBufferMemoryManager::getLargestFreeBlock ( )
static

Get the size of the largest available free block.

Return values
size_tSize in bytes of the largest contiguous free block

◆ getTotalFreeMemory()

size_t uniot::GlobalBufferMemoryManager::getTotalFreeMemory ( )
static

Get the total free memory available in the buffer.

Return values
size_tTotal bytes available across all free blocks

◆ initialize()

void uniot::GlobalBufferMemoryManager::initialize ( )
static

Initialize the memory manager.

Sets up the free list with a single large block covering the entire buffer. Must be called before any other memory operations.

◆ reallocate()

void * uniot::GlobalBufferMemoryManager::reallocate ( void * ptr,
size_t newSize )
static

Resize allocated memory.

Either returns the existing block if it's large enough, or allocates a new block, copies the data, and frees the old block.

Parameters
ptrPointer to memory previously allocated with allocate(), or nullptr
newSizeNew size in bytes
Return values
void*Pointer to the resized memory block
nullptrIf reallocation fails

The documentation for this class was generated from the following files: