summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJulian T <julian@T410.mynet>2018-09-05 21:26:17 +0200
committerJulian T <julian@T410.mynet>2018-09-05 21:26:17 +0200
commitc65cccf6c83150736d4ad7edfa15a0fc6994ff14 (patch)
tree091f73717f14c4b6c4a780029242b89a0abd9b00 /util.c
Added source
Diffstat (limited to 'util.c')
-rw-r--r--util.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..6b703e9
--- /dev/null
+++ b/util.c
@@ -0,0 +1,33 @@
+/* See LICENSE file for copyright and license details. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "util.h"
+
+void *
+ecalloc(size_t nmemb, size_t size)
+{
+ void *p;
+
+ if (!(p = calloc(nmemb, size)))
+ perror(NULL);
+ return p;
+}
+
+void
+die(const char *fmt, ...) {
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+
+ if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
+ fputc(' ', stderr);
+ perror(NULL);
+ }
+
+ exit(1);
+}