scopedAllocPush
Opens a new "scope" for allocations. All allocations made via the scopedAllocXyz() APIs will store their results into the current (most recently pushed) allocation scope for later cleanup. The returned value must be retained for passing to scopedAllocPop().
Any number of scopes may be active at once, but they must be popped in reverse order of their creation. i.e. they must nest in a manner equivalent to C-style scopes.
Warnings:
All the other scopedAllocXyz() routines will throw if no scope is active.
It is never legal to pass the result of a scoped allocation to dealloc(), and doing so will cause a double-free when the scope is closed with scopedAllocPop().
This function and its relatives have only a single intended usage pattern:
const scope = wasm.scopedAllocPush();
try {
... use scopedAllocXyz() routines ...
// It is perfectly legal to use non-scoped allocations here,
// they just won't be cleaned up when...
}finally{
wasm.scopedAllocPop(scope);
}Content copied to clipboard