fix minor memory leak
[ccc.git] / ast.c
diff --git a/ast.c b/ast.c
index f7748f6..622ba74 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -22,11 +22,6 @@ struct ast *ast(struct list *decls)
        return res;
 }
 
-struct vardecl vardecl(char *ident, struct expr *expr)
-{
-       return (struct vardecl) {.ident=ident, .expr=expr};
-}
-
 struct decl *decl_fun(char *ident, struct list *args, struct list *body)
 {
        struct decl *res = safe_malloc(sizeof(struct decl));
@@ -399,6 +394,7 @@ void ast_free(struct ast *ast)
                return;
        for (int i = 0; i<ast->ndecls; i++)
                decl_free(ast->decls[i]);
+       free(ast->decls);
        free(ast);
 }