Skip to content

Commit

Permalink
Fix some memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Victorious3 committed Feb 9, 2024
1 parent ad298da commit a7833b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/compiler.pr
Original file line number Diff line number Diff line change
Expand Up @@ -5453,6 +5453,7 @@ def walk_For_generator(node: &parser::Node, state: &State) {
last_node = n
}
let last_loc = make_location(last_node, state)
insert_destructor(locv, loc, state)
insert_destructors(node.inner_scope, last_loc, state)
pop_scope(state)

Expand Down Expand Up @@ -6942,7 +6943,7 @@ def create_free_context(function: &Function, state: &State) {
let label_ = state.make_label()
push_label(label_, state)
switch_values.push([
value = make_int_value(i + 1),
value = make_int_value(i),
label_ = label_
] !SwitchValue)

Expand Down Expand Up @@ -7388,6 +7389,12 @@ export def create_function(
generate_defer_types_pre(state)

if function.has_yield {
// Create new snapshot for arguments
let new_snapshot = map::make(int)
new_snapshot.put_all(function.current_snapshot)
function.current_snapshot = new_snapshot
function.snapshots.push(new_snapshot)

// Get is_at_end pointer
let is_at_end_gep = make_insn(InsnKind::GETELEMENTPTR)
is_at_end_gep.value.gep = [
Expand Down
2 changes: 1 addition & 1 deletion std/std.pr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ from strings export *
ref_roots = zero_allocate(type &map::Map(uint64, Root))
@ref_roots = map::make(uint64, Root)
}
(@ref_roots)(ref.value !uint64) = [ ref, make_string(file), line ] !Root
(@ref_roots)(ref.value !uint64) = [ ref = ref, file = make_string(file), line = line ] !Root
lock = l
}

Expand Down

0 comments on commit a7833b8

Please sign in to comment.