diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-01-26 17:54:23 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-01-26 17:54:23 -0800 |
| commit | de0fec8fcb2e09500b4665b07fdad6a2902d9c87 (patch) | |
| tree | 19f45a18380bf8ee8f252b8ec49e5068332850b9 /utils.c | |
| parent | d9cca805a005a0c64252ec47674d68a07ded86e5 (diff) | |
Removed check() and replaced with err()/errx()
Diffstat (limited to 'utils.c')
| -rw-r--r-- | utils.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -3,6 +3,7 @@ // #include <ctype.h> +#include <err.h> #include <stdlib.h> #include <unistd.h> @@ -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; } |
