WasmMemory.create constructor
Creates a new memory in store.
Implementation
factory WasmMemory.create(
WasmStore store, {
required int initial,
int? maximum,
}) => scoped((arena) {
final limits = arena<c.wasm_limits_t>()
..ref.min = initial
..ref.max = maximum ?? c.wasm_limits_max_default;
final type = c.wasm_memorytype_new(limits);
try {
final out = arena<c.wasmtime_memory_t>();
throwIfError(c.wasmtime_memory_new(store.context, type, out));
return WasmMemory._(store, readMemoryHandle(out.ref));
} finally {
c.wasm_memorytype_delete(type);
}
});