fix: merging all the code

This commit is contained in:
Matteo Flebus 2026-01-15 18:49:42 +01:00
parent 2e9e98d343
commit 1eecb1bd42
12 changed files with 86 additions and 61 deletions

View file

@ -2,25 +2,26 @@
#include <stdbool.h>
void ast_free(struct ast *node)
void ast_free(struct ast **node)
{
if (node == NULL)
if (*node == NULL)
return;
// ast void does not need to be freed.
if (ast_is_if(node))
ast_free_if(ast_get_if(node));
else if (ast_is_command(node))
ast_free_command(ast_get_command(node));
else if (ast_is_list(node))
ast_free_list(ast_get_list(node));
if (ast_is_if(*node))
ast_free_if(ast_get_if(*node));
else if (ast_is_command(*node))
ast_free_command(ast_get_command(*node));
else if (ast_is_list(*node))
ast_free_list(ast_get_list(*node));
free(node);
free(*node);
*node = NULL;
}
struct ast *ast_create(enum ast_type type, void *data)
{
struct ast *node = malloc(sizeof(struct ast));
if (!node)
if (node == NULL)
return NULL;
node->type = type;