From e5393671a265e1c301c6c303f21f938c4cf9ca75 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 2 Apr 2020 15:50:13 +0200 Subject: Evaluation pipe frame (not tested) --- src/path.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/path.c') diff --git a/src/path.c b/src/path.c index f1424cc..1576a66 100644 --- a/src/path.c +++ b/src/path.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/27 15:51:01 by cacharle #+# #+# */ -/* Updated: 2020/04/01 17:55:28 by charles ### ########.fr */ +/* Updated: 2020/04/03 07:17:04 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,16 +35,19 @@ static t_path st_path_dir_update(t_path path, char *dirname) { DIR *dir; struct dirent *entry; - char *tmp; + char *filepath; if ((dir = opendir(dirname)) == NULL) return (NULL); while ((entry = readdir(dir)) != NULL) { - if ((tmp = ft_strjoin3(dirname, "/", entry->d_name)) == NULL) - return (NULL); - if (ft_htset(path, entry->d_name, tmp, ht_del_str_entry) == NULL) + if ((filepath = ft_strjoin3(dirname, "/", entry->d_name)) == NULL || + ft_htset(path, entry->d_name, filepath, free) == NULL) + { + free(filepath); + closedir(dir); return (NULL); + } } if (closedir(dir) == -1) return (NULL); -- cgit