From 2e015152cf2a13515d706ecdf0002cbbab431c17 Mon Sep 17 00:00:00 2001 From: Nathan Lebrun Date: Thu, 6 Feb 2025 11:27:00 +0100 Subject: [PATCH] leaks --- includes/minishell.h | 2 +- includes/parser/ast.h | 1 + srcs/parsing/ast/and_or.c | 2 +- srcs/parsing/ast/cutll.c | 9 +++++++++ srcs/parsing/ast/pipeline.c | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/includes/minishell.h b/includes/minishell.h index c9f9c81..81ee1ea 100644 --- a/includes/minishell.h +++ b/includes/minishell.h @@ -13,7 +13,7 @@ #ifndef MINISHELL_H # define MINISHELL_H -# define DEBUG 1 +# define DEBUG 0 typedef struct s_ast_n t_ast_n; typedef struct s_node t_node; diff --git a/includes/parser/ast.h b/includes/parser/ast.h index 1241b9d..053b255 100644 --- a/includes/parser/ast.h +++ b/includes/parser/ast.h @@ -83,5 +83,6 @@ void create_and_or(t_ast_n *parrent, t_node *lst, t_node *token, t_msh *msh); // free void free_ast(t_ast_n *node); +void free_lltab(t_nodell *nodell); #endif diff --git a/srcs/parsing/ast/and_or.c b/srcs/parsing/ast/and_or.c index 3c57aaf..3dc78fa 100644 --- a/srcs/parsing/ast/and_or.c +++ b/srcs/parsing/ast/and_or.c @@ -19,5 +19,5 @@ void create_and_or(t_ast_n *self, t_node *lst, t_node *token, t_msh *msh) nodell = cutll(lst, token, 1); self->left = create_ast_n(nodell->node, self, msh, self->sh); self->right = create_ast_n(nodell->next->node, self, msh, self->sh); - // free_lltab(sublsts); + free_lltab(nodell); } diff --git a/srcs/parsing/ast/cutll.c b/srcs/parsing/ast/cutll.c index ed9017f..403901a 100644 --- a/srcs/parsing/ast/cutll.c +++ b/srcs/parsing/ast/cutll.c @@ -72,3 +72,12 @@ t_nodell *cutll(t_node *lst, t_node *expected, size_t limiter) } return (out); } + +void free_lltab(t_nodell *nodell) +{ + while (nodell) + { + free_linked_list(nodell->node); + nodell = nodell->next; + } +} diff --git a/srcs/parsing/ast/pipeline.c b/srcs/parsing/ast/pipeline.c index 9e905b2..45a9e20 100644 --- a/srcs/parsing/ast/pipeline.c +++ b/srcs/parsing/ast/pipeline.c @@ -37,5 +37,5 @@ void create_pline(t_ast_n *self, t_node *lst, t_node *token, t_msh *msh) i++; } cpy = NULL; - // free_lltab(sublsts); + free_lltab(nodell); }