Base Framework
Static Protected Member Functions | List of all members
HeapImpl Class Reference

Heap implementation. More...

#include <base/mem/Heap.h>

Inherited by Heap [private].

Static Protected Member Functions

static MemorySize getHeapUsed () noexcept
 
static void * allocateNoThrow (MemorySize size) noexcept
 
static void * allocate (MemorySize size)
 
static void * resize (void *heap, MemorySize size)
 
static void * tryResize (void *heap, MemorySize size)
 
static void release (void *heap)
 
static MemorySize getMinimumSize () noexcept
 
static MemorySize getSize (void *heap) noexcept
 

Detailed Description

Heap implementation.

This class encapsulates the implementation used by the Heap class. Do not use this class directly.

See also
Heap
Version
1.0

Member Function Documentation

◆ allocate()

static void* HeapImpl::allocate ( MemorySize  size)
staticprotected

Allocates the specified number of bytes on the heap. Raises MemoryException if unable to allocate the memory block. Returns nullptr for size 0.

Parameters
sizeThe desired size of the memory block in number of bytes.

◆ allocateNoThrow()

static void* HeapImpl::allocateNoThrow ( MemorySize  size)
staticprotectednoexcept

Allocates the specified number of bytes on the heap. Returns nullptr if unable to allocate the memory block. Returns nullptr for size 0.

Parameters
sizeThe desired size of the memory block in number of bytes.

◆ getHeapUsed()

static MemorySize HeapImpl::getHeapUsed ( )
staticprotectednoexcept

Returns the total heap used.

◆ getMinimumSize()

static MemorySize HeapImpl::getMinimumSize ( )
staticprotectednoexcept

Returns the minimum block size.

◆ getSize()

static MemorySize HeapImpl::getSize ( void *  heap)
staticprotectednoexcept

Returns the size of the memory block.

◆ release()

static void HeapImpl::release ( void *  heap)
staticprotected

Frees the specified memory block previously allocated by 'allocate' or 'reallocate'. Raises MemoryException if unable to free the memory.

Parameters
heapThe memory block.

◆ resize()

static void* HeapImpl::resize ( void *  heap,
MemorySize  size 
)
staticprotected

Resizes the specified memory block. Raises MemoryException if unable allocate memory block. Memory block may be moved when memory is made smaller. Returns nullptr for size 0.

Parameters
heapThe memory block.
sizeThe desired size of the memory block in number of bytes.

◆ tryResize()

static void* HeapImpl::tryResize ( void *  heap,
MemorySize  size 
)
staticprotected

Tries to resize the specified memory block without movement. Raises MemoryException on allocation failure.

Parameters
heapThe memory block.
sizeThe desired size of the memory block in number of bytes.
Returns
nullptr if unable to resize memory block or size was 0.