From 10ff285727e4c6e63690f29ff7d7002291452a36 Mon Sep 17 00:00:00 2001 From: gwojda Date: Wed, 15 Mar 2017 16:38:04 +0100 Subject: [PATCH] fixe some leaks --- 42sh/Makefile | 2 +- 42sh/includes/exec.h | 4 +--- 42sh/includes/minishell.h | 3 ++- 42sh/src/lexer/insert_newline.c | 5 +++-- 42sh/src/main/instruction_free.c | 9 +++++---- 42sh/src/main/main.c | 4 +--- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/42sh/Makefile b/42sh/Makefile index 7911a273..76d15b32 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -84,7 +84,6 @@ exec/ft_findexec.c\ exec/is_function.c\ exec/mark_process_status.c\ exec/node_copy.c\ -exec/op_stack_free.c\ exec/pfree_cmd.c\ exec/pfree_cond.c\ exec/pfree_list.c\ @@ -265,6 +264,7 @@ line-editing/print_and_del.c\ line-editing/queue.c\ line-editing/readline.c\ line-editing/resize.c\ +main/content_free.c\ main/data_exit.c\ main/data_init.c\ main/data_singleton.c\ diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index d5e2122f..200b2b7c 100644 --- a/42sh/includes/exec.h +++ b/42sh/includes/exec.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ -/* Updated: 2017/03/15 16:06:24 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 16:35:30 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -133,8 +133,6 @@ struct s_exec int control_count; }; -void op_stack_free(void *data, size_t content_size); - int exec_reset(void); int process_setgroup(t_process *p, pid_t pid); void process_setsig(void); diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index cf2d6d05..4d690594 100644 --- a/42sh/includes/minishell.h +++ b/42sh/includes/minishell.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */ -/* Updated: 2017/03/14 21:34:13 by jhalford ### ########.fr */ +/* Updated: 2017/03/15 16:35:42 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -54,6 +54,7 @@ void data_exit(void); int instruction_free(t_list **token, t_parser *parser, t_btree **ast); +void content_free(void *data, size_t content_size); char *ft_putast(void *node); void ft_putast2(void *node); diff --git a/42sh/src/lexer/insert_newline.c b/42sh/src/lexer/insert_newline.c index 8cd60a2a..47e7d1bf 100644 --- a/42sh/src/lexer/insert_newline.c +++ b/42sh/src/lexer/insert_newline.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/21 21:05:23 by ariard #+# #+# */ -/* Updated: 2017/03/08 18:33:31 by ariard ### ########.fr */ +/* Updated: 2017/03/15 16:31:49 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,5 +19,6 @@ int insert_newline(t_list **alst) token = token_init(); token->type = TK_NEWLINE; ft_lsteadd(alst, ft_lstnew(token, sizeof(*token))); + free(token); return (0); -} +} diff --git a/42sh/src/main/instruction_free.c b/42sh/src/main/instruction_free.c index 361923d1..03b4d989 100644 --- a/42sh/src/main/instruction_free.c +++ b/42sh/src/main/instruction_free.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/15 15:54:59 by gwojda #+# #+# */ -/* Updated: 2017/03/15 16:06:34 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 16:36:14 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,9 +16,10 @@ int instruction_free(t_list **token, t_parser *parser, t_btree **ast) { ft_lstdel(token, &token_free); token = NULL; - ft_lstdel(&parser->stack, NULL); - btree_del(ast, &ast_free); + ft_lstdel(&parser->stack, &content_free); + btree_del(ast, &content_free); ft_lstdel(&data_singleton()->heredoc_queue, &redir_free); - ft_lstdel(&data_singleton()->exec.op_stack, &op_stack_free); + ft_lstdel(&data_singleton()->exec.op_stack, &content_free); + free(parser->new_sym); return (0); } diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 32de297e..bf8cdd41 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/15 16:12:35 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 16:33:07 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -74,11 +74,9 @@ int handle_instruction(int fd) if (ft_exec(&ast)) return (2); instruction_free(&token, &parser, &ast); - ft_lstdel(&parser.stack, &op_stack_free); if (SH_IS_INTERACTIVE(data_singleton()->opts) && *lexer.str) ft_add_str_in_history(lexer.str); ft_strdel(&lexer.str); - free(parser.new_sym); return (0); }