refactor(ast): one file per ast_type -- UNSTABLE (3)

This commit is contained in:
Matteo Flebus 2026-01-15 15:53:56 +01:00
parent 68d8a1fd13
commit e3ec484621
9 changed files with 76 additions and 9 deletions

View file

@ -2,7 +2,22 @@
#include <stdbool.h>
static struct ast *ast_create(enum ast_type type, void *data)
void ast_free(struct ast *node)
{
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));
free(node);
}
struct ast *ast_create(enum ast_type type, void *data)
{
struct ast *node = malloc(sizeof(struct ast));
if (!node)