From b576eddd03e89aac09706bb3027def887641492d Mon Sep 17 00:00:00 2001 From: Gautier WOJDA Date: Thu, 2 Feb 2017 11:13:02 +0100 Subject: [PATCH] correction de leaks --- 42sh/Makefile | 2 +- 42sh/src/line-editing/check_backslash.c | 4 ++-- 42sh/src/line-editing/get_touch.c | 7 ++----- 42sh/src/line-editing/print_and_del.c | 4 ++-- 42sh/src/line-editing/readline.c | 4 ++-- 42sh/src/line-editing/toolz_parseur.c | 2 +- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/42sh/Makefile b/42sh/Makefile index b20dd88f..15ff6d83 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -13,7 +13,7 @@ NAME = 42sh CC = gcc -FLAGS = -Wall -Wextra -Werror +FLAGS = -Wall -Wextra -Werror -g D_FLAGS = -g DELTA = $$(echo "$$(tput cols)-47"|bc) diff --git a/42sh/src/line-editing/check_backslash.c b/42sh/src/line-editing/check_backslash.c index fa91a8ab..14e0fe22 100644 --- a/42sh/src/line-editing/check_backslash.c +++ b/42sh/src/line-editing/check_backslash.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 13:32:52 by gwojda #+# #+# */ -/* Updated: 2017/01/26 13:50:00 by gwojda ### ########.fr */ +/* Updated: 2017/02/02 11:11:11 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,7 @@ void ft_check_backslash(char **str) char *tmp1; char *tmp2; - if (!*str) + if (!*str || !**str) return ; if ((*str)[ft_strlen(*str) - 1] == '\\') { diff --git a/42sh/src/line-editing/get_touch.c b/42sh/src/line-editing/get_touch.c index 6668421f..eec81a25 100644 --- a/42sh/src/line-editing/get_touch.c +++ b/42sh/src/line-editing/get_touch.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 16:28:49 by gwojda #+# #+# */ -/* Updated: 2017/02/01 16:50:57 by gwojda ### ########.fr */ +/* Updated: 2017/02/02 10:38:58 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -112,11 +112,8 @@ char *ft_lecture(t_list_history *head) else if (ft_lecture_3(ret, &str, &i)) continue ; else if (ret == 10) - break ; + return (str); else if (ft_isascii(ret) == 0) ft_read_it(ret, &i, &str); } - if (str) - ft_putstr(str + i); - return (str); } diff --git a/42sh/src/line-editing/print_and_del.c b/42sh/src/line-editing/print_and_del.c index be81a660..e4100b9b 100644 --- a/42sh/src/line-editing/print_and_del.c +++ b/42sh/src/line-editing/print_and_del.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/05 16:02:43 by gwojda #+# #+# */ -/* Updated: 2017/02/01 15:25:19 by gwojda ### ########.fr */ +/* Updated: 2017/02/02 11:12:29 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,7 +49,7 @@ void ft_suppr_2(char **str, size_t *i, size_t tmp) ft_putnc('\b', *i - tmp); (*i) = tmp; if (ft_strlen(*str) == 0) - *str = NULL; + ft_strdel(str); } void ft_suppr(char **str, size_t *i) diff --git a/42sh/src/line-editing/readline.c b/42sh/src/line-editing/readline.c index 09a58998..b5be9b33 100644 --- a/42sh/src/line-editing/readline.c +++ b/42sh/src/line-editing/readline.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ -/* Updated: 2017/01/26 13:38:29 by gwojda ### ########.fr */ +/* Updated: 2017/02/02 10:41:26 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -70,7 +70,7 @@ int ft_readline(void) if (tcsetattr(0, TCSANOW, ft_stats_term_termcaps()) == -1) return (-1); if (data_singleton()->line.input) - data_singleton()->line.input = NULL; + ft_strdel(&data_singleton()->line.input); ft_prompt(); data_singleton()->line.input = ft_lecture(data_singleton()->line.list_beg); ft_putchar('\n'); diff --git a/42sh/src/line-editing/toolz_parseur.c b/42sh/src/line-editing/toolz_parseur.c index 557027b3..50f2c532 100644 --- a/42sh/src/line-editing/toolz_parseur.c +++ b/42sh/src/line-editing/toolz_parseur.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/16 16:14:46 by gwojda #+# #+# */ -/* Updated: 2017/01/25 11:51:30 by gwojda ### ########.fr */ +/* Updated: 2017/02/02 11:01:10 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */