From: Dominik Kaiser Date: Mon, 25 Mar 2024 10:59:40 +0000 (+0100) Subject: Code works now as it should. X-Git-Url: https://git.dkaiser.de/?a=commitdiff_plain;h=baa1352385373ebdfcffa6272d9ca3a19cbf1210;p=42%2Fget_next_line.git Code works now as it should. TODO: Refactoring and some improvements Other than that, the code works fine and should pass eval after norminette has been dealt with. --- diff --git a/get_next_line.c b/get_next_line.c index 7b43e06..4f28a34 100644 --- a/get_next_line.c +++ b/get_next_line.c @@ -6,7 +6,7 @@ /* By: dkaiser 0) get_next_line_rec(fd, buf, &result, 0); } @@ -92,6 +111,13 @@ char *get_next_line(int fd) if (i == BUFFER_SIZE) { readlen = read(fd, buf, BUFFER_SIZE); + if (readlen < 0) + { + i = 0; + while (i < BUFFER_SIZE) + buf[i++] = '\0'; + return (NULL); + } if (readlen > 0) return (get_next_line(fd)); return (NULL); diff --git a/get_next_line_utils.c b/get_next_line_utils.c index 6127736..690be2a 100644 --- a/get_next_line_utils.c +++ b/get_next_line_utils.c @@ -6,7 +6,7 @@ /* By: dkaiser