From f640ceee89836b56ac95c4eb1b0a43d1171c3354 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 17 May 2023 00:19:14 +0200 Subject: General improvements (nothing special, mainly cleanup and docs) --- src/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index b2d86eb..a5faa80 100644 --- a/src/main.c +++ b/src/main.c @@ -12,7 +12,6 @@ #include #include #include -#include // automatically generated using gengetopt #include "cmdline.h" @@ -25,7 +24,7 @@ static char *read_stdin(void) size_t size = 1; char *string = malloc(sizeof(char) * BUF_SIZE); if (!string) - return 0; + fatal("out of memory!\n"); string[0] = '\0'; while (fgets(buffer, BUF_SIZE, stdin)) { char *old = string; @@ -57,6 +56,8 @@ static char *read_file(const char *path) fseek(f, 0, SEEK_SET); char *string = malloc(fsize + 1); + if (!string) + fatal("out of memory!\n"); int ret = fread(string, fsize, 1, f); fclose(f); -- cgit v1.2.3