Base Framework
Static Public Member Functions | List of all members
Heap Class Reference

Heap provider. More...

#include <base/mem/Heap.h>

Inherits HeapImpl.

Static Public Member Functions

static MemorySize getMinimumSize () noexcept
 
template<class TYPE >
static TYPE * allocateNoThrow (MemorySize size) noexcept
 
template<class TYPE >
static TYPE * allocate (MemorySize size)
 
template<class TYPE >
static TYPE * resize (TYPE *heap, MemorySize size)
 
static bool canResizeInplace () noexcept
 
template<class TYPE >
static TYPE * tryResize (void *heap, MemorySize size)
 
template<class TYPE >
static void release (TYPE *heap)
 
template<class TYPE >
static MemorySize getSize (TYPE *heap) noexcept
 
static void onLeak (const Type *type, void *buffer, MemorySize size)
 
static MemorySize align64 (MemorySize offset) noexcept
 
static MemorySize align32 (MemorySize offset) noexcept
 
static MemorySize align16 (MemorySize offset) noexcept
 
static MemorySize align (MemorySize offset) noexcept
 

Detailed Description

Heap provider.

Heap. Wrapper for memory allocation on the heap.

Version
1.0

Member Function Documentation

◆ align()

static MemorySize Heap::align ( MemorySize  offset)
inlinestaticnoexcept

Adjusts offset to 16 bytes alignment.

◆ align16()

static MemorySize Heap::align16 ( MemorySize  offset)
inlinestaticnoexcept

Adjusts offset to 16 bytes alignment.

◆ align32()

static MemorySize Heap::align32 ( MemorySize  offset)
inlinestaticnoexcept

Adjusts offset to 32 bytes alignment.

◆ align64()

static MemorySize Heap::align64 ( MemorySize  offset)
inlinestaticnoexcept

Adjusts offset to 64 bytes alignment.

◆ allocate()

template<class TYPE >
static TYPE* Heap::allocate ( MemorySize  size)
inlinestatic

Allocates the specified number of bytes on the heap. Raises MemoryException if unable to allocate the memory block.

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

◆ allocateNoThrow()

template<class TYPE >
static TYPE* Heap::allocateNoThrow ( MemorySize  size)
inlinestaticnoexcept

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

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

◆ canResizeInplace()

static bool Heap::canResizeInplace ( )
inlinestaticnoexcept

Returns true if inplace reallocation is supported.

◆ getMinimumSize()

static MemorySize Heap::getMinimumSize ( )
inlinestaticnoexcept

Returns the minimum block size.

◆ getSize()

template<class TYPE >
static MemorySize Heap::getSize ( TYPE *  heap)
inlinestaticnoexcept

Returns the size of the memory block.

Parameters
heapThe memory block.

◆ onLeak()

static void Heap::onLeak ( const Type type,
void *  buffer,
MemorySize  size 
)
static

Called to register heap leaks.

◆ release()

template<class TYPE >
static void Heap::release ( TYPE *  heap)
inlinestatic

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

Parameters
heapThe memory block.

◆ resize()

template<class TYPE >
static TYPE* Heap::resize ( TYPE *  heap,
MemorySize  size 
)
inlinestatic

Resizes the specified memory block. Raises MemoryException if unable allocate memory block.

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

◆ tryResize()

template<class TYPE >
static TYPE* Heap::tryResize ( void *  heap,
MemorySize  size 
)
inlinestatic

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 elements.
Returns
nullptr if unable to resize memory block or size was 0.