aboutsummaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-26 17:54:23 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-26 17:54:23 -0800
commitde0fec8fcb2e09500b4665b07fdad6a2902d9c87 (patch)
tree19f45a18380bf8ee8f252b8ec49e5068332850b9 /utils.c
parentd9cca805a005a0c64252ec47674d68a07ded86e5 (diff)
Removed check() and replaced with err()/errx()
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/utils.c b/utils.c
index 63a06fe..997223c 100644
--- a/utils.c
+++ b/utils.c
@@ -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;
}