cohtml::IVirtualAllocator

Virtual memory allocator interface used by Cohtml for scripting memory allocations.

#include <Library.h>

Public Functions

Name
IVirtualAllocator()
virtual~IVirtualAllocator()
virtual size_tGetAllocationPageSize() const =0
virtual size_tGetCommitPageSize() const =0
virtual void *Allocate(void * address, size_t size, size_t alignment, int protection, int flags) =0
Reserve and/or commit a memory region.
virtual boolFree(void * address, size_t size, int flags) =0
Releases or decommits a memory region.

Public Functions Documentation

function IVirtualAllocator

IVirtualAllocator()

function ~IVirtualAllocator

virtual ~IVirtualAllocator()

function GetAllocationPageSize

virtual size_t GetAllocationPageSize() const =0

Return: the page granularity for reserving memory.

function GetCommitPageSize

virtual size_t GetCommitPageSize() const =0

Return: the page granularity for committing memory.

function Allocate

virtual void * Allocate(
    void * address,
    size_t size,
    size_t alignment,
    int protection,
    int flags
) =0

Reserve and/or commit a memory region.

Parameters:

  • address a hint when reserving memory and a concrete address when committing.
  • size the number of bytes to allocate.
  • alignment the required alignment for the return address.
  • protection specifies a protection type for the memory region.
  • flags type of the allocation (commit, reserve or reserve & commit).

Return: address of the allocated memory region.

function Free

virtual bool Free(
    void * address,
    size_t size,
    int flags
) =0

Releases or decommits a memory region.

Parameters:

  • address a concrete address to release or decommit.
  • size the number of bytes to deallocate.
  • flags type of the deallocation (decommit or release).

Return: true if the function succeeds, otherwise false.

Note: A release call is expected to also decommit the memory.