diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-01-24 18:52:32 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-01-24 18:52:32 +0100 |
commit | 0e55e163397f2b109321ad284d298e60ee3b97a7 (patch) | |
tree | f30aacccaefc5c063a2a6840f02d2e02bdef6b90 /src/ft_get_sprite_tex.c | |
parent | Correct (diff) | |
download | 42-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 '')
-rw-r--r-- | src/ft_get_sprite_tex.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/src/ft_get_sprite_tex.c b/src/ft_get_sprite_tex.c index 5dbe4b4..4cec41a 100644 --- a/src/ft_get_sprite_tex.c +++ b/src/ft_get_sprite_tex.c @@ -2,20 +2,6 @@ #include <cub3d.h> #include <stdlib.h> -static void -ft_check_empty_line(int fd, unsigned int linum, t_win *wlist) -{ - char *line; - - get_next_line(fd, &line); - if (*line) - { - ft_memdel(line); - ft_map_error(linum, wlist); - } - ft_memdel(line); -} - int ft_get_sprite_tex(int fd, t_win *wlist) { @@ -23,22 +9,25 @@ ft_get_sprite_tex(int fd, t_win *wlist) char **words; size_t len; - ft_check_empty_line(fd, 6, wlist); get_next_line(fd, &line); if (!(words = ft_split(line, ' '))) + { + ft_memdel(line); return (ft_exit(5, wlist)); - if (!(*words) || ft_strcmp(*words, "S") - || !(*(words + 1)) || (*(words + 2))) + } + if (!(*words) || ft_strcmp(*words, "S") || !words[1] || words[2]) { - ft_free_words(words); + ft_free_words(words, line); return (ft_map_error(7, wlist)); } ft_memdel(wlist->clist->sprite_path); len = ft_strlen(*(words + 1)); if (!(wlist->clist->sprite_path = (char*)malloc((len + 1) * sizeof(char)))) + { + ft_free_words(words, line); return (-1); + } ft_strlcpy(wlist->clist->sprite_path, *(words + 1), len + 1); - ft_free_words(words); - ft_memdel(line); + ft_free_words(words, line); return (0); } |