Struct Region

Bump-pointer region allocator for WASM, modelled after std.experimental.allocator.building_blocks.region.Region.

struct Region(uint minAlign = 8);

A Region manages a caller-supplied contiguous block of memory as a simple bump-the-pointer allocator. Individual deallocations are not supported; instead the entire region is released at once via deallocateAll.

The backing storage is *not* embedded; the caller supplies a contiguous block via initialize.

Methods

NameDescription
allocate (n) Allocates n bytes with at least alignment-byte alignment.
available () Returns the number of bytes still available.
deallocateAll () Releases all allocations, resetting the region to empty.
empty () Returns true if no allocations have been made.
initialize (store) Initialises this region to manage the buffer at store.
makeArray (length) Allocates a typed array of length elements.
makeOpaqueArray (n) Allocates a ubyte[] buffer of n bytes.
owns (b) Queries whether b was allocated from this region.

Parameters

NameDescription
minAlign minimum alignment for all returned allocations; must be a positive power of two

See Also

WasmAllocator, newWasmAllocator