From 21b89ad57984a5caae0374fee3ee69dcdaf480e2 Mon Sep 17 00:00:00 2001 From: Rory Bradford Date: Sun, 5 Jun 2022 12:13:36 +0100 Subject: Use fgets instead of getline. Signed-off-by: Rory Bradford --- ignore.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ignore.c') diff --git a/ignore.c b/ignore.c index c247692..d859d46 100644 --- a/ignore.c +++ b/ignore.c @@ -6,6 +6,7 @@ #include #include +#include "rf.h" #include "ignore.h" static int total_size; @@ -18,15 +19,14 @@ struct ignores *init_ignores(char *path) { return NULL; } - char *line = NULL; - size_t llen = 0; + char line[MAX_PATH_LENGTH]; total_size = IGNORE_SIZE; struct ignores *ignores = (struct ignores *)calloc(sizeof(struct ignores), 1); ignores->list = (char **)calloc(sizeof(char *), IGNORE_SIZE); ignores->size = 0; - while (getline(&line, &llen, ignore) != -1) { + while (fgets(line, MAX_PATH_LENGTH, ignore) != NULL) { /** isspace doesn't necessarily hold true for `\n` for anything * other than the 'C' locale on some platforms, so we have to do * an additional check for this @@ -64,7 +64,6 @@ struct ignores *init_ignores(char *path) { } } - free(line); fclose(ignore); ignores->size = i; -- cgit 1.4.1-2-gfad0