From 3fe40e249fbad468347b2a0d643b19f1f5f3f524 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 29 Jan 2020 23:21:16 +0100 Subject: I've seen enough --- src/ft_get_map_redo.c | 90 --------------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 src/ft_get_map_redo.c (limited to 'src/ft_get_map_redo.c') diff --git a/src/ft_get_map_redo.c b/src/ft_get_map_redo.c deleted file mode 100644 index 2f020f9..0000000 --- a/src/ft_get_map_redo.c +++ /dev/null @@ -1,90 +0,0 @@ -#include -#include -#include -#include - -static void -ft_linecpy(char *line, char *mapl, size_t start) -{ - size_t i; - size_t j; - size_t slen; - - i = 0; - j = start; - slen = ft_strlen(line); - while (i < slen && line[i]) - { - while (line[i] == ' ') - i++; - mapl[j] = line[i]; - i++; - j++; - } - mapl[j] = '\n'; -} - -static int8_t -ft_cat_mapl(char *line, size_t i, t_cub *clist) -{ - if (!(clist->mapl = (char *)ft_nrealloc(clist->mapl, - ((clist->map_w + 1) * i) * sizeof(char), - ((clist->map_w + 1) * (i + 1)) * sizeof(char)))) - return (-1); - ft_linecpy(line, clist->mapl, (clist->map_w + 1) * i); - return (0); -} - -int -ft_get_map_first_line(char *line, t_cub *clist) -{ - if (!line[0]) - { - ft_memdel(line); - return (-1); - } - clist->map_w = ft_get_line_len(line); - if (ft_check_map_line(line, 1, clist) < 0) - { - ft_memdel(line); - return (-1); - } - clist->mapl = NULL; - if (ft_cat_mapl(line, 0, clist) < 0) - { - ft_memdel(line); - return (-1); - } - ft_memdel(line); - return (1); -} - -int -ft_get_map_core(int fd, t_cub *clist) -{ - int ret; - size_t i; - char *line; - - i = 1; - ret = 1; - while (ret > 0) - { - clist->line_chk += 1; - ret = get_next_line(fd, &line); - if (ret < 0) - return (-1); - if (!line[0] || ft_check_map_line(line, 0, clist) < 0 - || ft_cat_mapl(line, i, clist) < 0) - { - ft_memdel(line); - return (-1); - } - i++; - } - clist->mapl[((clist->map_w + 1) * i) - 1] = '\0'; - ft_free_words(clist->map); - clist->map = ft_split(clist->mapl, '\n'); - ft_memdel(clist->mapl); - return (0); -} -- cgit v1.2.3