Interface MemoryAllocator

All Known Implementing Classes:
BumpAllocator

public interface MemoryAllocator
Allocates and frees memory within WebAssembly linear memory.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    allocate(int size, int alignment)
    Allocates a block of memory with the given size and alignment.
    void
    free(int pointer, int size, int alignment)
    Frees a previously allocated block of memory.
  • Method Details

    • allocate

      int allocate(int size, int alignment)
      Allocates a block of memory with the given size and alignment.
      Parameters:
      size - the number of bytes to allocate
      alignment - the required alignment in bytes (must be a power of 2)
      Returns:
      the offset in linear memory where the block was allocated
    • free

      void free(int pointer, int size, int alignment)
      Frees a previously allocated block of memory.
      Parameters:
      pointer - the offset of the block to free
      size - the size of the block in bytes
      alignment - the alignment of the block