42sh/src/utils/ast/ast_list.c
2026-01-15 17:12:06 +01:00

33 lines
663 B
C

#include "utils/ast/ast.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;
return ast_create(AST_LIST, ast_list);
}
struct ast_list *ast_get_list(struct ast *node)
{
assert(node != NULL);
return (struct ast_list*)node->data;
}
bool ast_is_list(struct ast *node)
{
return node->type == AST_LIST;
}
void ast_free_list(struct ast_list **ast_list)
{
if (*ast_list == NULL || ast_list == NULL)
return;
list_deep_destroy((*ast_list)->children);
free(*ast_list);
*ast_list = NULL;
}