withWasmArena<T> function

T withWasmArena<T>(
  1. NitroWasmModule module,
  2. T action(
    1. WasmArena arena
    )
)

Runs action with a scoped WasmArena over module, freeing all arena allocations afterwards — the web analog of withArena/using.

Implementation

T withWasmArena<T>(NitroWasmModule module, T Function(WasmArena arena) action) {
  final arena = WasmArena(module);
  try {
    return action(arena);
  } finally {
    arena.releaseAll();
  }
}