aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorc2023-11-26 07:52:51 -0500
committerc2023-11-26 07:52:51 -0500
commit097a03435f322962d785d5ecd6883901882fd6c2 (patch)
tree9653cb3f79f94c1b83ed3381e8f3d8a8838508fd /src
parentbf3767fa7f0f1687d930d0d137e76a0206545fd6 (diff)
Destroying trees.
Diffstat (limited to 'src')
-rw-r--r--src/main.c2
-rw-r--r--src/parser.c2
-rw-r--r--src/tree.c3
3 files changed, 4 insertions, 3 deletions
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: