diff options
Diffstat (limited to 'src/ft_get_res.c')
-rw-r--r-- | src/ft_get_res.c | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/ft_get_res.c b/src/ft_get_res.c index 92e0890..79df8a3 100644 --- a/src/ft_get_res.c +++ b/src/ft_get_res.c @@ -2,21 +2,7 @@ #include <cub3d.h> static void -ft_free_words(char **words) -{ - size_t i; - - i = 0; - while (words[i]) - { - ft_memdel(words[i]); - i++; - } - ft_memdel(words); -} - -static void -ft_checkdigit(const char *word) +ft_checkdigit(const char *word, t_win *wlist) { size_t i; @@ -24,7 +10,7 @@ ft_checkdigit(const char *word) while (ft_isdigit(word[i])) i++; if (i != ft_strlen(word)) - ft_map_error(1); + ft_map_error(1, wlist); } int @@ -33,15 +19,14 @@ ft_get_res(int fd, t_win *wlist) char *line; char **words; - (void)wlist; get_next_line(fd, &line); if (!(words = ft_split(line, ' '))) - return (ft_exit(5)); + return (ft_exit(5, wlist)); if (!(*words) || ft_strcmp(*words, "R") || !(*(words + 1)) || !(*(words + 2)) || (*(words + 3))) - ft_map_error(1); - ft_checkdigit(words[1]); - ft_checkdigit(words[2]); + return (ft_map_error(1, wlist)); + ft_checkdigit(words[1], wlist); + ft_checkdigit(words[2], wlist); wlist->x_size = ft_atoi(words[1]); wlist->y_size = ft_atoi(words[2]); ft_free_words(words); |