summaryrefslogtreecommitdiff
path: root/src/io
diff options
context:
space:
mode:
authorLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2024-07-23 00:02:27 +0200
committerLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2024-07-23 00:02:27 +0200
commit93394b388f7cbec6640e361aa95c3b30ba2a90fc (patch)
tree40a30f58d39f01f3eaf9df9446b14edd9b09b534 /src/io
parentbd22d0e47d0fb203286b088f048cf1aff1fa93a1 (diff)
global progname variable
Diffstat (limited to 'src/io')
-rw-r--r--src/io/lines.c4
-rw-r--r--src/io/read_file.c5
2 files changed, 5 insertions, 4 deletions
diff --git a/src/io/lines.c b/src/io/lines.c
index fd9c3a5..e5de6df 100644
--- a/src/io/lines.c
+++ b/src/io/lines.c
@@ -12,7 +12,7 @@ bool file_lines_open(const char *progname, const char *fname, FILE *f, struct fi
dst->cap = 4096;
dst->buffer = malloc(dst->cap);
if (!dst->buffer) {
- print_error_nomem(progname);
+ print_error_nomem();
return false;
}
@@ -56,7 +56,7 @@ bool file_lines_read(struct file_lines *fl, struct string_view *dst) {
}
DEBUG("realloc to cap %zu\n", fl->cap);
fl->buffer = realloc(fl->buffer, fl->cap);
- if (!fl->buffer) print_error_nomem(fl->progname);
+ if (!fl->buffer) print_error_nomem();
}
size_t nr = fread(fl->buffer + fl->cursor, 1, fl->cap - fl->cursor, fl->f);
diff --git a/src/io/read_file.c b/src/io/read_file.c
index 2ff00a5..99bea2a 100644
--- a/src/io/read_file.c
+++ b/src/io/read_file.c
@@ -5,10 +5,11 @@
#include <unistd.h>
#include "read_file.h"
+#include "global.h"
#define CHECK_OOM(ptr) \
if (ptr == NULL) { \
- fprintf(stderr, "geheugen is op\n"); \
+ fprintf(stderr, "%s: geheugen is op\n", progname); \
/* I think I should free the original memory here, but whatever */ \
return NULL; \
}
@@ -35,7 +36,7 @@ struct filebuf *stream_to_filebuf(FILE *restrict stream, int openOptions) {
sz += n;
if (n != amount && !feof(stream)) {
- fprintf(stderr, "fout tijdens lezen van standaard invoer.\n");
+ fprintf(stderr, "%s: fout tijdens lezen van standaard invoer.\n", progname);
free(buf);
return NULL;
}