Skip to content
SiteEmail

cohtml::IVirtualAllocator

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

#include <Library.h>

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.
virtual boolPartialFree(void * address, size_t oldSize, size_t newSize, int flags) =0
Releases or decommits part of a memory region.
IVirtualAllocator()
virtual ~IVirtualAllocator()
virtual size_t GetAllocationPageSize() const =0

Return: the page granularity for reserving memory.

virtual size_t GetCommitPageSize() const =0

Return: the page granularity for committing memory.

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.

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.

virtual bool PartialFree(
void * address,
size_t oldSize,
size_t newSize,
int flags
) =0

Releases or decommits part of a memory region.

Parameters:

  • address a address of the start of the region.
  • oldSize the original size of the region
  • newSize the new size of the region
  • flags type of the deallocation (decommit or release).

Return: true if the function succeeds, otherwise false.