From 0d4f441670bda3e1078d475137fa3255c5f172c4 Mon Sep 17 00:00:00 2001 From: gwojda Date: Tue, 14 Mar 2017 16:37:40 +0100 Subject: [PATCH] rip leaks --- 42sh/libft | 2 +- 42sh/src/builtin/builtin_exit.c | 4 ++-- 42sh/src/completion/c_glob_matching.c | 3 +-- 42sh/src/history/list_toolz.c | 8 ++++++-- 42sh/src/line-editing/ft_prompt.c | 10 ++++++---- 42sh/src/main/data_exit.c | 6 ++++-- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/42sh/libft b/42sh/libft index b209bb1f..9382dc10 160000 --- a/42sh/libft +++ b/42sh/libft @@ -1 +1 @@ -Subproject commit b209bb1fb718a68256253d5ab5ff69a46a90d5d6 +Subproject commit 9382dc10fdb91892ab26604a5776e5301ab88b71 diff --git a/42sh/src/builtin/builtin_exit.c b/42sh/src/builtin/builtin_exit.c index c4b4fd7f..e08a3563 100644 --- a/42sh/src/builtin/builtin_exit.c +++ b/42sh/src/builtin/builtin_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */ -/* Updated: 2017/03/13 14:52:53 by jhalford ### ########.fr */ +/* Updated: 2017/03/14 15:22:44 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,9 +36,9 @@ int builtin_exit(const char *path, char *const av[], char *const envp[]) ft_save_termios(-1); ft_free_hash_table(); free_history_list(data_singleton()->line.list_beg); - data_exit(); if (SH_IS_INTERACTIVE(data_singleton()->opts)) tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes); + data_exit(); exit(status); return (0); } diff --git a/42sh/src/completion/c_glob_matching.c b/42sh/src/completion/c_glob_matching.c index 66f39d9d..4ff64652 100644 --- a/42sh/src/completion/c_glob_matching.c +++ b/42sh/src/completion/c_glob_matching.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 17:20:01 by gwojda #+# #+# */ -/* Updated: 2017/03/10 17:43:15 by gwojda ### ########.fr */ +/* Updated: 2017/03/14 14:00:30 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -63,7 +63,6 @@ int c_glob_matching(void) glob_echap = (unsigned char *)ft_strnew(ft_strlen(str) >> 3); ft_bzero(glob_echap, ft_strlen(str) >> 3); ss_glob = glob(current_word, glob_echap, glob_echap, 1); -// ss_glob = glob(current_word, glob_echap, glob_echap); free(current_word); if (!*ss_glob || !**ss_glob || !ft_strncmp(str + pos, *ss_glob, ft_strlen(*ss_glob))) return (0); diff --git a/42sh/src/history/list_toolz.c b/42sh/src/history/list_toolz.c index a12fd6a8..abdf45fd 100644 --- a/42sh/src/history/list_toolz.c +++ b/42sh/src/history/list_toolz.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/17 11:37:47 by gwojda #+# #+# */ -/* Updated: 2017/03/13 14:47:06 by jhalford ### ########.fr */ +/* Updated: 2017/03/14 15:20:22 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,11 +18,15 @@ void free_history_list(t_list_history *head) if (!head) return ; + DG("free hist"); + if (head->next) + free(head->next); while (head) { ft_strdel(&head->str); prev = head; - head = head->next; + head = head->prev; + free(prev); } } diff --git a/42sh/src/line-editing/ft_prompt.c b/42sh/src/line-editing/ft_prompt.c index b8ea9529..cda5a0ad 100644 --- a/42sh/src/line-editing/ft_prompt.c +++ b/42sh/src/line-editing/ft_prompt.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */ -/* Updated: 2017/03/14 12:32:38 by gwojda ### ########.fr */ +/* Updated: 2017/03/14 16:00:05 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,16 +24,18 @@ static int promt_git_status(int fd) line = ft_strdup(ft_strrchr(line, '/') + 1); else line = ft_strdup(line + 3); - ft_printf("\x1b[38;5;47mgit:(\x1b[38;5;203m%s\x1b[38;5;47m)", line); free(tmp); + ft_printf("\x1b[38;5;47mgit:(\x1b[38;5;203m%s\x1b[38;5;47m)", line); if (!get_next_line(fd, &tmp)) printf("\x1b[38;5;83m %C ", L'✓'); else { printf("\x1b[38;5;1m %C ", L'✗'); - while (get_next_line(fd, &tmp)) - free(tmp); + free(tmp); } + while (get_next_line(fd, &tmp)) + free(tmp); + free(tmp); len = ft_strlen(line); ft_strdel(&line); fflush(NULL); diff --git a/42sh/src/main/data_exit.c b/42sh/src/main/data_exit.c index 30acbb44..27f59f26 100644 --- a/42sh/src/main/data_exit.c +++ b/42sh/src/main/data_exit.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* data_exit.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */ -/* Updated: 2017/01/22 17:20:29 by ariard ### ########.fr */ +/* Updated: 2017/03/14 15:21:17 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,4 +19,6 @@ void data_exit(void) data = data_singleton(); /* ft_strdel(&data->line.input); */ ft_sstrfree(data->env); + ft_sstrfree(data->argv); + free(data_singleton()); }