From 28b2a059a54a73565fabbded0ca5a68e5b59df5a Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 20 Mar 2017 12:27:36 +0100 Subject: [PATCH] fix leak redir --- 42sh/includes/lexer.h | 7 +++---- 42sh/includes/parser.h | 5 ++--- 42sh/libft/src/lst/ft_lstmap.c | 6 ++++-- 42sh/libft/src/lst/ft_lstnew.c | 2 +- 42sh/libft/src/math/id.c | 12 ++++++++++++ 42sh/src/exec/process_set.c | 2 +- 42sh/src/exec/redir_copy.c | 2 +- 42sh/src/exec/redir_free.c | 2 +- 42sh/src/job_control/builtin_fg.c | 3 +-- 42sh/src/job_control/do_job_notification.c | 5 ++--- 42sh/src/job_control/job_update_status.c | 2 +- 11 files changed, 29 insertions(+), 19 deletions(-) diff --git a/42sh/includes/lexer.h b/42sh/includes/lexer.h index a0bc1ed1..d8961da0 100644 --- a/42sh/includes/lexer.h +++ b/42sh/includes/lexer.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */ -/* Updated: 2017/03/19 17:13:05 by wescande ### ########.fr */ +/* Updated: 2017/03/20 11:51:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -63,9 +63,8 @@ struct s_rvwords int type; }; -extern t_rvwords g_rvwords[]; - -extern int (*g_lexer[])(t_list **alst, t_lexer *lexer); +/* extern t_rvwords g_rvwords[]; */ +/* extern int (*g_lexer[])(t_list **alst, t_lexer *lexer); */ int ft_post_tokenize(t_list **alst, char **str); diff --git a/42sh/includes/parser.h b/42sh/includes/parser.h index 6bd7ac30..1fa276a9 100644 --- a/42sh/includes/parser.h +++ b/42sh/includes/parser.h @@ -94,8 +94,6 @@ struct s_treematch int (*add)(t_btree **ast, t_list **lst); }; -extern t_treematch g_treematch[]; - int build_tree(t_btree **ast, t_list **lst); int add_sep(t_btree **ast, t_list **lst); @@ -153,7 +151,8 @@ struct s_distrostree int (*add)(t_btree **ast, t_list **lst); }; -extern t_distrostree g_distrostree[]; +/* extern t_distrostree g_distrostree[]; */ +/* extern t_treematch g_treematch[]; */ struct s_redir { diff --git a/42sh/libft/src/lst/ft_lstmap.c b/42sh/libft/src/lst/ft_lstmap.c index 3b422790..3a36ef41 100644 --- a/42sh/libft/src/lst/ft_lstmap.c +++ b/42sh/libft/src/lst/ft_lstmap.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:21 by jhalford #+# #+# */ -/* Updated: 2017/03/08 12:03:14 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:25:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,9 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *)) if (!lst) return (NULL); - elem = ft_lstnew((*f)(lst->content), lst->content_size); + if (!(elem = (t_list *)malloc(sizeof(*elem)))) + return (NULL); + elem->content = (*f)(lst->content); elem->next = ft_lstmap(lst->next, f); return (elem); } diff --git a/42sh/libft/src/lst/ft_lstnew.c b/42sh/libft/src/lst/ft_lstnew.c index e85e8c62..17a43d6f 100644 --- a/42sh/libft/src/lst/ft_lstnew.c +++ b/42sh/libft/src/lst/ft_lstnew.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/29 15:57:38 by jhalford #+# #+# */ -/* Updated: 2017/03/13 15:41:27 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:23:44 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/math/id.c b/42sh/libft/src/math/id.c index 938cb5d1..e23a5831 100644 --- a/42sh/libft/src/math/id.c +++ b/42sh/libft/src/math/id.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* id.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/20 12:20:59 by jhalford #+# #+# */ +/* Updated: 2017/03/20 12:21:01 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" void *id(void *data) diff --git a/42sh/src/exec/process_set.c b/42sh/src/exec/process_set.c index 69f451ff..b2ce7cfc 100644 --- a/42sh/src/exec/process_set.c +++ b/42sh/src/exec/process_set.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */ -/* Updated: 2017/03/20 11:38:35 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:22:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/redir_copy.c b/42sh/src/exec/redir_copy.c index 055efcd4..5dd758c9 100644 --- a/42sh/src/exec/redir_copy.c +++ b/42sh/src/exec/redir_copy.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 00:02:58 by ariard #+# #+# */ -/* Updated: 2017/03/13 14:20:56 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:21:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/redir_free.c b/42sh/src/exec/redir_free.c index 0e04cec2..2cc00e05 100644 --- a/42sh/src/exec/redir_free.c +++ b/42sh/src/exec/redir_free.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/03 18:12:57 by ariard #+# #+# */ -/* Updated: 2017/03/20 11:39:40 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:21:21 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/builtin_fg.c b/42sh/src/job_control/builtin_fg.c index 0201de78..dfbe6104 100644 --- a/42sh/src/job_control/builtin_fg.c +++ b/42sh/src/job_control/builtin_fg.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/08 14:30:07 by jhalford #+# #+# */ -/* Updated: 2017/03/20 11:00:49 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:12:16 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,7 +37,6 @@ int builtin_fg(const char *path, char *const av[], char *const envp[]) } else { - DG("rank:%i:%i", rank[0], rank[1]); if ((jlist = ft_lst_find(jobc->first_job, &rank[0], job_cmp_id))) job_run(jlist->content, 1); else if ((jlist = ft_lst_find(jobc->first_job, &rank[1], job_cmp_id))) diff --git a/42sh/src/job_control/do_job_notification.c b/42sh/src/job_control/do_job_notification.c index 8bec9af4..a86208a8 100644 --- a/42sh/src/job_control/do_job_notification.c +++ b/42sh/src/job_control/do_job_notification.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */ -/* Updated: 2017/03/18 00:07:12 by wescande ### ########.fr */ +/* Updated: 2017/03/20 12:15:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,8 +27,7 @@ int do_job_notification(void) { j = jlist->content; jlist = jlist->next; - if (job_is_completed(j->id) - || (job_is_stopped(j->id) && !(j->attrs & JOB_NOTIFIED))) + if ((job_is_stopped(j->id) && !(j->attrs & JOB_NOTIFIED))) { ret = 1; job_notify_change(j->id); diff --git a/42sh/src/job_control/job_update_status.c b/42sh/src/job_control/job_update_status.c index 7fca5ea1..c518decb 100644 --- a/42sh/src/job_control/job_update_status.c +++ b/42sh/src/job_control/job_update_status.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */ -/* Updated: 2017/03/16 18:32:15 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:12:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */