refactor(ast): one file per ast_type -- UNSTABLE (3)
This commit is contained in:
parent
68d8a1fd13
commit
e3ec484621
9 changed files with 76 additions and 9 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue