Skip to content

Commit

Permalink
gc works mostly
Browse files Browse the repository at this point in the history
  • Loading branch information
ShawSumma committed Jul 13, 2024
1 parent 98efe96 commit 77d15a6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion main/minivm.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int main(int argc, char **argv) {
const char *src;
bool f_flag = true;
if (!strcmp(arg, "-e")) {
src = argv[i++];
src = vm_strdup(argv[i++]);
} else {
f_flag = !strcmp(arg, "-f");
if (f_flag) {
Expand Down Expand Up @@ -119,6 +119,8 @@ int main(int argc, char **argv) {
printf("%.*s", (int)buf.len, buf.buf);
}

vm_free(src);

if (!f_flag) {
break;
}
Expand Down
2 changes: 0 additions & 2 deletions vm/lua/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,6 @@ vm_ast_node_t vm_lang_lua_parse(vm_t *vm, const char *str, const char *file) {
}

vm_block_t *vm_compile(vm_t *vm, const char *src, const char *file) {
src = vm_strdup(src);
file = vm_strdup(file);
vm_ast_node_t ast = vm_lang_lua_parse(vm, src, file);
vm_blocks_srcs_t *next = vm_malloc(sizeof(vm_blocks_srcs_t));
*next = (vm_blocks_srcs_t){
Expand Down
1 change: 1 addition & 0 deletions vm/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void vm_state_delete(vm_t *vm) {
while (cur != NULL) {
vm_blocks_srcs_t *last = cur->last;
vm_free(cur->data);
vm_free(cur);
cur = last;
}
}
Expand Down

0 comments on commit 77d15a6

Please sign in to comment.