diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-04-02 15:50:13 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-04-03 08:57:45 +0200 |
| commit | e5393671a265e1c301c6c303f21f938c4cf9ca75 (patch) | |
| tree | 0190ff9ba762cf820b1846b01adc339092370e2c /src/path.c | |
| parent | f66cb8f28a2779159baeef6ea91a7684d59cc295 (diff) | |
| download | minishell-e5393671a265e1c301c6c303f21f938c4cf9ca75.tar.gz minishell-e5393671a265e1c301c6c303f21f938c4cf9ca75.tar.bz2 minishell-e5393671a265e1c301c6c303f21f938c4cf9ca75.zip | |
Evaluation pipe frame (not tested)
Diffstat (limited to 'src/path.c')
| -rw-r--r-- | src/path.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); |
