From de0fec8fcb2e09500b4665b07fdad6a2902d9c87 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 26 Jan 2021 17:54:23 -0800 Subject: Removed check() and replaced with err()/errx() --- utils.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'utils.c') diff --git a/utils.c b/utils.c index 63a06fe..997223c 100644 --- a/utils.c +++ b/utils.c @@ -3,6 +3,7 @@ // #include +#include #include #include @@ -123,10 +124,8 @@ char unescapechar(const char *escaped, const char **end) // void *memcheck(void *p) { - if (p == NULL) { - fprintf(stderr, "memory allocation failure\n"); - exit(EXIT_FAILURE); - } + if (p == NULL) + err(EXIT_FAILURE, "memory allocation failure"); return p; } @@ -147,10 +146,8 @@ int memicmp(const void *v1, const void *v2, size_t n) // void xfree(void *p) { - if (*(void**)p == NULL) { - fprintf(stderr, "Attempt to free(NULL)\n"); - exit(EXIT_FAILURE); - } + if (*(void**)p == NULL) + errx(EXIT_FAILURE, "attempt to free(NULL)"); free(*(void**)p); p = NULL; } -- cgit v1.2.3