From 78817b6b8c1db9993dd6b854abb3a1fe35ce4f88 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Thu, 17 Apr 2025 23:16:16 +0100 Subject: [PATCH] update: use updated parser api to fix memory leaks --- frontend/cmd/compile.c | 9 +++++---- frontend/cmd/repl.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/cmd/compile.c b/frontend/cmd/compile.c index f960a25..1aa0207 100644 --- a/frontend/cmd/compile.c +++ b/frontend/cmd/compile.c @@ -82,7 +82,7 @@ static int compile_file(const char *path, const b_arglist *args) if (status != IVY_OK) { b_err("failed to initialise Ivy code generator"); - ivy_parser_destroy(parser); + ivy_parser_destroy(parser, NULL); ivy_lexer_destroy(lex); ivy_file_close(src); return -1; @@ -146,12 +146,12 @@ static int compile_file(const char *path, const b_arglist *args) } if (r != 0) { - ivy_parser_destroy(parser); + ivy_parser_destroy(parser, NULL); return r; } if (!show_ir) { - ivy_parser_destroy(parser); + ivy_parser_destroy(parser, NULL); return 0; } @@ -175,10 +175,11 @@ static int compile_file(const char *path, const b_arglist *args) mie_ir_converter_set_dest_file(convert, stdout); mie_ir_converter_process(convert); + mie_value_destroy(MIE_VALUE(mod)); mie_ir_converter_destroy(convert); ivy_codegen_destroy(codegen); - ivy_parser_destroy(parser); + ivy_parser_destroy(parser, NULL); return r; } diff --git a/frontend/cmd/repl.c b/frontend/cmd/repl.c index 727678f..230aebd 100644 --- a/frontend/cmd/repl.c +++ b/frontend/cmd/repl.c @@ -101,7 +101,7 @@ static void repl_destroy(struct repl *repl) } if (repl->r_parse) { - ivy_parser_destroy(repl->r_parse); + ivy_parser_destroy(repl->r_parse, NULL); } if (repl->r_lex) {