diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /21sh/ll-expr/src/ast/ast.c | |
Diffstat (limited to '21sh/ll-expr/src/ast/ast.c')
| -rw-r--r-- | 21sh/ll-expr/src/ast/ast.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/21sh/ll-expr/src/ast/ast.c b/21sh/ll-expr/src/ast/ast.c new file mode 100644 index 0000000..701d40e --- /dev/null +++ b/21sh/ll-expr/src/ast/ast.c @@ -0,0 +1,27 @@ +#include "ast.h" + +#include <err.h> +#include <stdlib.h> + +struct ast *ast_new(enum ast_type type) +{ + struct ast *new = calloc(1, sizeof(struct ast)); + if (!new) + return NULL; + new->type = type; + return new; +} + +void ast_free(struct ast *ast) +{ + if (ast == NULL) + return; + + ast_free(ast->left); + ast->left = NULL; + + ast_free(ast->right); + ast->right = NULL; + + free(ast); +} |
