Skip to content

Commit

Permalink
Adding deinit for function instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Southporter committed Jun 13, 2024
1 parent a3b7ae6 commit ed2e5b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/instance.zig
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub const ExportError = error{

pub const TrapError = error{
TrapDebug,
TrapInvalidResume,
TrapUnreachable,
TrapIntegerDivisionByZero,
TrapIntegerOverflow,
Expand Down
10 changes: 10 additions & 0 deletions src/vm_stack.zig
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ const FunctionInstance = struct {
def_index: usize,
instructions_begin: usize,
local_types: std.ArrayList(ValType),

fn deinit(func: *FunctionInstance) void {
func.local_types.deinit();
}
};

const Label = struct {
Expand Down Expand Up @@ -5253,7 +5257,13 @@ pub const StackVM = struct {

pub fn deinit(vm: *VM) void {
var self: *StackVM = fromVM(vm);

for (self.functions.items) |*func| {
func.deinit();
}

self.functions.deinit();

self.stack.deinit();
if (self.debug_state) |*debug_state| {
debug_state.trapped_opcodes.deinit();
Expand Down

0 comments on commit ed2e5b5

Please sign in to comment.