Clean up after function call
This commit is contained in:
@@ -729,6 +729,11 @@ struct GroundExecutionResult _GroundBytecodeInstructionExecute(GroundBytecodeIns
|
||||
Ground.Log.Error("malloc failed in Ground.Bytecode.Instruction.execute");
|
||||
Ground.Flags.error = true;
|
||||
return CONTINUE;
|
||||
} else {
|
||||
// forget all values in previous closure
|
||||
for (GroundSize i = 0; i < function->closure->len; i++) {
|
||||
Ground.Free.BytecodeValue(&function->closure->heap[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (GroundSize i = 0; i < heap->len; i++) {
|
||||
@@ -785,6 +790,12 @@ struct GroundExecutionResult _GroundBytecodeInstructionExecute(GroundBytecodeIns
|
||||
// And store the result
|
||||
HEAP_SET(heap, instruction->args.at[instruction->args.len - 1], result);
|
||||
|
||||
// Clean up the new heap
|
||||
for (GroundSize i = 0; i < newHeap.len; i++) {
|
||||
Ground.Free.BytecodeValue(&newHeap.heap[i]);
|
||||
}
|
||||
free(newHeap.heap);
|
||||
|
||||
return CONTINUE;
|
||||
}
|
||||
CALLMETHOD: {
|
||||
|
||||
Reference in New Issue
Block a user