CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
CYB::API::Heap Class Referenceabstract

An interface which can allocate memory. More...

#include <Heap.hpp>

Inheritance diagram for CYB::API::Heap:
Inheritance graph
[legend]

Public Member Functions

virtual void * Alloc (const int ASize)=0
 Allocate memory from the heap for use. More...
 
virtual void * Realloc (void *const APreviousAllocation, const int ANewSize)=0
 Allocate memory from the heap for use while preserving previous data. Passing a valid APreviousAllocation with ANewSize of zero is equivalent to calling Free(APreviousAllocation) More...
 
virtual void Free (void *const APreviousAllocation) noexcept=0
 Return memory to the heap. Data in allocated range will be lost. More...
 

Detailed Description

An interface which can allocate memory.

Definition at line 5 of file Heap.hpp.

Member Function Documentation

virtual void* CYB::API::Heap::Alloc ( const int  ASize)
pure virtual

Allocate memory from the heap for use.

Parameters
ASizeThe amount of bytes to allocate
Returns
The beginning of an allocated memory region with size at least ASize
Thread Safety
This function requires no thread safety
Exceptions
CYB::Exception::ViolationError code: CYB::Exception::Violation::NEGATIVE_HEAP_ALLOCATION. Thrown if an allocation was attempted with a negative size value
CYB::Exception::SystemDataError code: CYB::Exception::SystemData::MEMORY_COMMITAL_FAILURE. Thrown if the heap does not have the space for the allocation and more system memory cannot be requested
Attention
Allocations above 2047MB are unsupported

Implemented in CYB::Engine::Memory::Heap.

Here is the caller graph for this function:

virtual void CYB::API::Heap::Free ( void *const  APreviousAllocation)
pure virtualnoexcept

Return memory to the heap. Data in allocated range will be lost.

Parameters
APreviousAllocationA pointer previously returned from a call to Alloc or Realloc of the same Heap object
Thread Safety
This function requires no thread safety

Implemented in CYB::Engine::Memory::Heap.

Here is the caller graph for this function:

virtual void* CYB::API::Heap::Realloc ( void *const  APreviousAllocation,
const int  ANewSize 
)
pure virtual

Allocate memory from the heap for use while preserving previous data. Passing a valid APreviousAllocation with ANewSize of zero is equivalent to calling Free(APreviousAllocation)

Parameters
APreviousAllocationA pointer previously returned from a call to Alloc or Realloc of the same Heap object
ANewSizeThe amount of bytes to allocate or zero to free an allocation from APreviousAllocation. Must be less than 2047MB
Returns
The beginning of an allocated memory region with size at least ANewSize and the data from APreviousAllocation. Or, if ANewSize was less than or equal to zero, nullptr
Thread Safety
This function requires no thread safety
Exceptions
CYB::Exception::ViolationError code: CYB::Exception::Violation::NEGATIVE_HEAP_ALLOCATION. Thrown if an allocation was attempted with a negative size value
CYB::Exception::ViolationError code: CYB::Exception::Violation::UNSUPPORTED_ALLOCATION_AMOUNT if ANewSize is greater than or equal to 2047MB
CYB::Exception::SystemDataError code: CYB::Exception::SystemData::HEAP_ALLOCATION_FAILURE if the heap does not have the space for the allocation and more system memory cannot be requested

Implemented in CYB::Engine::Memory::Heap.


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