cohtml::IAllocator
On this page
Allocator interface used by Cohtml for all memory allocations. The user has to provide an object that implements this interface. Memory allocations in Cohtml are tagged, so the user knows the relative distribution of memory among subsystems.
#include <Library.h>
Public Functions
| Name | |
|---|---|
| IAllocator() | |
| virtual void * | Allocate(unsigned size, cohtml::MemTags::MemTagsType memtag) =0 Allocate size bytes. |
| virtual void * | Reallocate(void * ptr, unsigned size, cohtml::MemTags::MemTagsType memtag) =0 Reallocates the given area of memory. It must be previously allocated by Allocate. |
| virtual void | Deallocate(void * ptr, cohtml::MemTags::MemTagsType memtag) =0 Deallocates the memory previously allocated by Allocate. |
| virtual void * | AlignedAllocate(unsigned size, unsigned alignment, cohtml::MemTags::MemTagsType memtag) =0 Allocate size bytes whose alignment is specified by alignment. |
| virtual void | AlignedDeallocate(void * ptr, cohtml::MemTags::MemTagsType memtag) =0 Deallocates the memory previously allocated by AlignedAllocate. |
| virtual | ~IAllocator() |
Public Functions Documentation
function IAllocator
IAllocator()
function Allocate
virtual void * Allocate(
unsigned size,
cohtml::MemTags::MemTagsType memtag
) =0
Allocate size bytes.
Parameters:
- size the number of bytes to allocate
- memtag tag of the subsystem from which the request came
Return: the pointer to the beginning of newly allocated memory.
Warning: the memory must be aligned on 8
function Reallocate
virtual void * Reallocate(
void * ptr,
unsigned size,
cohtml::MemTags::MemTagsType memtag
) =0
Reallocates the given area of memory. It must be previously allocated by Allocate.
Parameters:
- ptr the pointer to the memory area to be reallocated
- size number of bytes to allocate
- memtag tag of the subsystem from which the request came
function Deallocate
virtual void Deallocate(
void * ptr,
cohtml::MemTags::MemTagsType memtag
) =0
Deallocates the memory previously allocated by Allocate.
Parameters:
- ptr the pointer to the memory to deallocate
- memtag tag of the subsystem from which the request came
function AlignedAllocate
virtual void * AlignedAllocate(
unsigned size,
unsigned alignment,
cohtml::MemTags::MemTagsType memtag
) =0
Allocate size bytes whose alignment is specified by alignment.
Parameters:
- size number of bytes to allocate
- alignment specifies the alignment
- memtag tag of the subsystem from which the request came
Return: the pointer to the beginning of newly allocated memory
Warning: when specified, memory alignment for allocations should be preserved
function AlignedDeallocate
virtual void AlignedDeallocate(
void * ptr,
cohtml::MemTags::MemTagsType memtag
) =0
Deallocates the memory previously allocated by AlignedAllocate.
Parameters:
- ptr the pointer to the memory to deallocate
- memtag tag of the subsystem from which the request came
function ~IAllocator
virtual ~IAllocator()