fix: merging all the code
This commit is contained in:
parent
2e9e98d343
commit
1eecb1bd42
12 changed files with 86 additions and 61 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue