From 097a03435f322962d785d5ecd6883901882fd6c2 Mon Sep 17 00:00:00 2001 From: c Date: Sun, 26 Nov 2023 07:52:51 -0500 Subject: Destroying trees. --- src/main.c | 2 +- src/parser.c | 2 +- src/tree.c | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 11ab70a..3c1b8b8 100644 --- a/src/main.c +++ b/src/main.c @@ -53,8 +53,8 @@ int main(int argc, char* argv[]) { /* Clean up parser stuff. */ token_destroy(lexer->tokenl); - tree_destroy(parser->tree); lexer_destroy(lexer); + tree_destroy(parser->tree); parser_destroy(parser); free(src); diff --git a/src/parser.c b/src/parser.c index c378d75..af6887e 100644 --- a/src/parser.c +++ b/src/parser.c @@ -56,7 +56,7 @@ tree_t* parser_parse_lstr(parser_t* parser) { lstr->data.lstr.len = strlen(parser->token->val); /* Swap pointers to allow for future token destruction. */ lstr->data.lstr.val = parser->token->val; - parser->token->val = NULL; + parser->token->val = NULL; return lstr; } diff --git a/src/tree.c b/src/tree.c index 4720ae6..4cd0263 100644 --- a/src/tree.c +++ b/src/tree.c @@ -19,6 +19,7 @@ tree_t* tree_init(int type) { tree->data.lint.val = 0; break; case TREE_TYPE_LSTR: + tree->data.lstr.val = NULL; tree->data.lstr.len = 0; break; case TREE_TYPE_TAG: @@ -72,7 +73,7 @@ void tree_destroy(tree_t* tree) { tree_destroy(tree->data.darg.nxt); break; case TREE_TYPE_CARG: - free(tree->data.carg.val); + tree_destroy(tree->data.carg.val); tree_destroy(tree->data.carg.nxt); break; case TREE_TYPE_DEF: -- cgit v1.2.3