safeUsing<R> method

R safeUsing<R>(
  1. R computation(
    1. Arena
    ), [
  2. Allocator? allocator
])

Runs the provided computation function within an Arena, ensuring that all allocations are released upon completion.

If allocator is provided, it is used for allocations; otherwise, the default allocator from the library is used.

This method is useful when multiple wasm modules are loaded and it ensures that the library-specific allocator is used.

Returns the result of the computation.

Implementation

R safeUsing<R>(R Function(Arena) computation, [Allocator? allocator]) {
  return using(computation, allocator ?? _library.memory);
}