diff options
| author | Rory Bradford <roryrjb@gmail.com> | 2022-06-05 12:13:36 +0100 |
|---|---|---|
| committer | Rory Bradford <roryrjb@gmail.com> | 2022-06-05 12:20:04 +0100 |
| commit | 21b89ad57984a5caae0374fee3ee69dcdaf480e2 (patch) | |
| tree | 555940d65cc10745d8ed858fb4f4a1e2c4766513 | |
| parent | 0e5b784369d18467ced409c204e0f2191646e309 (diff) | |
| download | rf-21b89ad57984a5caae0374fee3ee69dcdaf480e2.tar.gz | |
Use fgets instead of getline.
Signed-off-by: Rory Bradford <roryrjb@gmail.com>
| -rw-r--r-- | ignore.c | 7 | ||||
| -rw-r--r-- | rf.h | 1 |
2 files changed, 4 insertions, 4 deletions
@@ -6,6 +6,7 @@ #include <stdlib.h> #include <string.h> +#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; @@ -0,0 +1 @@ +#define MAX_PATH_LENGTH 1024 |