From 1e754c1256dfe2380fa8933802ea9b4e5518be48 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 20 Oct 2019 08:33:30 +0200 Subject: Passed moulitest large_file test --- get_next_line.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'get_next_line.c') diff --git a/get_next_line.c b/get_next_line.c index 0a5b001..47b85d2 100644 --- a/get_next_line.c +++ b/get_next_line.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/19 09:08:36 by cacharle #+# #+# */ -/* Updated: 2019/10/20 07:39:13 by cacharle ### ########.fr */ +/* Updated: 2019/10/20 08:29:44 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -42,7 +42,8 @@ int get_next_line(int fd, char **line) if (fd < 0 || line == NULL) return (ERROR); - had_rest = put_rest(line, rest); + if ((had_rest = put_rest(line, rest)) == -1) + return (LINE_READ); while (rest[0] == '\0' && (ret = read(fd, buf, BUFFER_SIZE)) > 0) { buf[ret] = '\0'; @@ -74,6 +75,8 @@ int put_rest(char **line, char *rest) rest[0] = '\0'; return (had_rest); } + if (split_at + 1 == ft_strlen(rest)) + had_rest = -1; *line = malloc(sizeof(char) * (split_at + 1)); ft_strncpy(*line, rest, split_at); (*line)[split_at] = '\0'; -- cgit