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

@ -1,12 +1,14 @@
#include "utils/ast/ast.h"
#include <assert.h>
struct ast *ast_create_list(struct list *list)
{
struct ast_list *ast_list = malloc(sizeof(struct ast_list));
if (ast_list == NULL)
return NULL;
ast_list->list = list;
ast_list->children = list;
return ast_create(AST_LIST, ast_list);
}
@ -22,12 +24,25 @@ bool ast_is_list(struct ast *node)
return node->type == AST_LIST;
}
void ast_free_list(struct ast_list **ast_list)
void ast_free_list(struct ast_list *ast_list)
{
if (*ast_list == NULL || ast_list == NULL)
if (ast_list == NULL)
return;
list_deep_destroy((*ast_list)->children);
free(*ast_list);
*ast_list = NULL;
list_deep_destroy(ast_list->children);
free(ast_list);
}
void ast_list_deep_destroy(struct list *l)
{
struct list *elt = l;
struct list *next_elt;
while (elt != NULL)
{
next_elt = elt->next;
ast_free(elt->data);
free(elt);
elt = next_elt;
}
}