diff options
author | c | 2023-11-26 07:52:51 -0500 |
---|---|---|
committer | c | 2023-11-26 07:52:51 -0500 |
commit | 097a03435f322962d785d5ecd6883901882fd6c2 (patch) | |
tree | 9653cb3f79f94c1b83ed3381e8f3d8a8838508fd | |
parent | bf3767fa7f0f1687d930d0d137e76a0206545fd6 (diff) |
Destroying trees.
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/parser.c | 2 | ||||
-rw-r--r-- | src/tree.c | 3 |
3 files changed, 4 insertions, 3 deletions
@@ -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; } @@ -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: |