From a6231aed863a7658fd1c9e90492839c2c937a846 Mon Sep 17 00:00:00 2001 From: adjoly Date: Thu, 1 Aug 2024 20:10:06 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix:=20when=20?= =?UTF-8?q?infile=20not=20here?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libft/src/linked_lists/ft_lstclear.c | 5 ++--- libft/src/linked_lists/ft_lstdelone.c | 5 +++-- src/parsing/get_cmd_list.c | 5 +++-- src/utils/free_list.c | 11 +++++++---- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libft/src/linked_lists/ft_lstclear.c b/libft/src/linked_lists/ft_lstclear.c index 1810e2f..1dbf0bb 100644 --- a/libft/src/linked_lists/ft_lstclear.c +++ b/libft/src/linked_lists/ft_lstclear.c @@ -6,7 +6,7 @@ /* By: mmoussou next; - if ((*lst)->content) - ft_lstdelone(*lst, del); + ft_lstdelone(*lst, del); *lst = tmp; } } diff --git a/libft/src/linked_lists/ft_lstdelone.c b/libft/src/linked_lists/ft_lstdelone.c index feb14c3..585ca42 100644 --- a/libft/src/linked_lists/ft_lstdelone.c +++ b/libft/src/linked_lists/ft_lstdelone.c @@ -6,7 +6,7 @@ /* By: mmoussou content); + if (lst->content) + del(lst->content); free(lst); lst = NULL; } diff --git a/src/parsing/get_cmd_list.c b/src/parsing/get_cmd_list.c index 90aed11..d8f2039 100644 --- a/src/parsing/get_cmd_list.c +++ b/src/parsing/get_cmd_list.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/31 12:47:13 by adjoly #+# #+# */ -/* Updated: 2024/08/01 18:07:13 by adjoly ### ########.fr */ +/* Updated: 2024/08/01 19:07:28 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,7 +41,8 @@ t_list *get_cmd_list(t_list *list) tmp = tmp->next; while (tmp) { - ft_lstadd_back(&cmd_list, make_lst(tmp)); + ft_lstadd_back(&cmd_list, ft_lstnew(get_redir_fd(tmp->content, \ + ((t_token *)tmp->content)->redirection))); if (!ft_lstlast(cmd_list)->content) { ft_lstclear(&cmd_list, &free_cmd); diff --git a/src/utils/free_list.c b/src/utils/free_list.c index de790cf..e5c8bce 100644 --- a/src/utils/free_list.c +++ b/src/utils/free_list.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/04 20:10:35 by adjoly #+# #+# */ -/* Updated: 2024/08/01 17:40:10 by adjoly ### ########.fr */ +/* Updated: 2024/08/01 19:15:44 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,9 +27,12 @@ void free_token(void *token_v) t_token *token; token = token_v; - free(token->argv); - ft_lstclear(&(token->redirection), free_redir); - free(token); + if (token->argv) + free(token->argv); + if (token->redirection) + ft_lstclear(&(token->redirection), free_redir); + if (token) + free(token); } void free_cmd(void *content)