From 90d901345abcbb271653fbee6749a2b3273fb62e Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 1 Nov 2023 17:52:15 +0000 Subject: Added a routine to cleanup resources allocated to the VM This means the stack should be heap allocated, which makes sense as beyond 1KB one should really be using the heap rather than the stack. --- vm/runtime.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'vm/runtime.c') diff --git a/vm/runtime.c b/vm/runtime.c index 240ba6f..3279354 100644 --- a/vm/runtime.c +++ b/vm/runtime.c @@ -325,6 +325,13 @@ void vm_load_registers(vm_t *vm, registers_t registers) vm->registers = registers; } +void vm_stop(vm_t *vm) +{ + free(vm->registers.data); + free(vm->program.instructions); + free(vm->stack.data); +} + void vm_print_registers(vm_t *vm, FILE *fp) { registers_t reg = vm->registers; -- cgit v1.2.3-13-gbd6f