From baa1352385373ebdfcffa6272d9ca3a19cbf1210 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Mon, 25 Mar 2024 11:59:40 +0100 Subject: [PATCH] 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. --- get_next_line.c | 32 +++++++++++++++++++++++++++++--- get_next_line_utils.c | 12 ++++++------ 2 files changed, 35 insertions(+), 9 deletions(-) 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