aboutsummaryrefslogtreecommitdiffstats
path: root/libft
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p2.le-101.fr>2020-02-28 20:36:49 +0100
committerRudy Bousset <rbousset@z2r5p2.le-101.fr>2020-02-28 20:36:49 +0100
commitfc792e8616d54defb50d26ed65b99cf91c18fe39 (patch)
treed775f0c586c136da0a9400c195bd4374811f99e4 /libft
parentL is now crapaud and you can pass through :^) (diff)
download42-cub3d-fc792e8616d54defb50d26ed65b99cf91c18fe39.tar.gz
42-cub3d-fc792e8616d54defb50d26ed65b99cf91c18fe39.tar.bz2
42-cub3d-fc792e8616d54defb50d26ed65b99cf91c18fe39.tar.xz
42-cub3d-fc792e8616d54defb50d26ed65b99cf91c18fe39.tar.zst
42-cub3d-fc792e8616d54defb50d26ed65b99cf91c18fe39.zip
GNL fix
Diffstat (limited to 'libft')
-rw-r--r--libft/src/get_next_line.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/libft/src/get_next_line.c b/libft/src/get_next_line.c
index 64ca7fc..4ace77a 100644
--- a/libft/src/get_next_line.c
+++ b/libft/src/get_next_line.c
@@ -21,7 +21,7 @@ static uint8_t
size_t i;
i = 0;
- while (str && str[i])
+ while (str[i] != '\0')
{
if (str[i] == '\n')
return (1);
@@ -56,12 +56,12 @@ static int
buff[ret] = '\0';
tmp = *str;
*str = ft_strjoin(tmp, buff);
- free(tmp);
+ ft_memdel((void**)&tmp);
}
if (ret < 0)
{
- free(*str);
- free(buff);
+ ft_memdel((void**)&str);
+ ft_memdel((void**)&buff);
return (-1);
}
free(buff);
@@ -75,7 +75,7 @@ static int
*str = ft_nstr(0);
if (fd < 0 || !line || BUFFER_SIZE <= 0)
{
- free(*str);
+ ft_memdel((void**)&str);
return (-1);
}
return (0);
@@ -102,10 +102,10 @@ int
if (ret == 0 && ((str == NULL || str[0] == '\0') || !ft_linecheck(str)))
{
i = tmp[i];
- free(tmp);
- tmp = NULL;
+ if (i == '\n')
+ ft_memdel((void**)&tmp);
return (i == '\n');
}
- free(tmp);
+ ft_memdel((void**)&tmp);
return (1);
}