aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_get_tex.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-01-24 18:52:32 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-01-24 18:52:32 +0100
commit0e55e163397f2b109321ad284d298e60ee3b97a7 (patch)
treef30aacccaefc5c063a2a6840f02d2e02bdef6b90 /src/ft_get_tex.c
parentCorrect (diff)
download42-cub3d-0e55e163397f2b109321ad284d298e60ee3b97a7.tar.gz
42-cub3d-0e55e163397f2b109321ad284d298e60ee3b97a7.tar.bz2
42-cub3d-0e55e163397f2b109321ad284d298e60ee3b97a7.tar.xz
42-cub3d-0e55e163397f2b109321ad284d298e60ee3b97a7.tar.zst
42-cub3d-0e55e163397f2b109321ad284d298e60ee3b97a7.zip
cleaner frees
Diffstat (limited to 'src/ft_get_tex.c')
-rw-r--r--src/ft_get_tex.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c
index 652f4af..0e394dc 100644
--- a/src/ft_get_tex.c
+++ b/src/ft_get_tex.c
@@ -11,20 +11,25 @@ ft_get_tex_no(int fd, t_win *wlist)
get_next_line(fd, &line);
if (!(words = ft_split(line, ' ')))
+ {
+ ft_memdel(line);
return (ft_exit(5, wlist));
+ }
if (!(*words) || ft_strcmp(*words, "NO")
|| !(*(words + 1)) || (*(words + 2)))
{
- ft_free_words(words);
+ ft_free_words(words, line);
return (ft_map_error(2, wlist));
}
ft_memdel(wlist->clist->no_tex_path);
len = ft_strlen(*(words + 1));
if (!(wlist->clist->no_tex_path = (char*)malloc((len + 1) * sizeof(char))))
+ {
+ ft_free_words(words, line);
return (-1);
+ }
ft_strlcpy(wlist->clist->no_tex_path, *(words + 1), len + 1);
- ft_free_words(words);
- ft_memdel(line);
+ ft_free_words(words, line);
return (0);
}
@@ -37,20 +42,25 @@ ft_get_tex_so(int fd, t_win *wlist)
get_next_line(fd, &line);
if (!(words = ft_split(line, ' ')))
+ {
+ ft_memdel(line);
return (ft_exit(5, wlist));
+ }
if (!(*words) || ft_strcmp(*words, "SO")
|| !(*(words + 1)) || (*(words + 2)))
{
- ft_free_words(words);
+ ft_free_words(words, line);
return (ft_map_error(3, wlist));
}
ft_memdel(wlist->clist->so_tex_path);
len = ft_strlen(*(words + 1));
if (!(wlist->clist->so_tex_path = (char*)malloc((len + 1) * sizeof(char))))
+ {
+ ft_free_words(words, line);
return (-1);
+ }
ft_strlcpy(wlist->clist->so_tex_path, *(words + 1), len + 1);
- ft_free_words(words);
- ft_memdel(line);
+ ft_free_words(words, line);
return (0);
}
@@ -63,20 +73,25 @@ ft_get_tex_we(int fd, t_win *wlist)
get_next_line(fd, &line);
if (!(words = ft_split(line, ' ')))
+ {
+ ft_memdel(line);
return (ft_exit(5, wlist));
+ }
if (!(*words) || ft_strcmp(*words, "WE")
|| !(*(words + 1)) || (*(words + 2)))
{
- ft_free_words(words);
+ ft_free_words(words, line);
return (ft_map_error(4, wlist));
}
ft_memdel(wlist->clist->we_tex_path);
len = ft_strlen(*(words + 1));
if (!(wlist->clist->we_tex_path = (char*)malloc((len + 1) * sizeof(char))))
+ {
+ ft_free_words(words, line);
return (-1);
+ }
ft_strlcpy(wlist->clist->we_tex_path, *(words + 1), len + 1);
- ft_free_words(words);
- ft_memdel(line);
+ ft_free_words(words, line);
return (0);
}
@@ -89,20 +104,25 @@ ft_get_tex_ea(int fd, t_win *wlist)
get_next_line(fd, &line);
if (!(words = ft_split(line, ' ')))
+ {
+ ft_memdel(line);
return (ft_exit(5, wlist));
+ }
if (!(*words) || ft_strcmp(*words, "EA")
|| !(*(words + 1)) || (*(words + 2)))
{
- ft_free_words(words);
+ ft_free_words(words, line);
return (ft_map_error(5, wlist));
}
ft_memdel(wlist->clist->ea_tex_path);
len = ft_strlen(*(words + 1));
if (!(wlist->clist->ea_tex_path = (char*)malloc((len + 1) * sizeof(char))))
+ {
+ ft_free_words(words, line);
return (-1);
+ }
ft_strlcpy(wlist->clist->ea_tex_path, *(words + 1), len + 1);
- ft_free_words(words);
- ft_memdel(line);
+ ft_free_words(words, line);
return (0);
}