aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/dwm/util.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-06-06 16:42:59 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-06-06 16:42:59 -0700
commit20b38eb32bd4118b283f791db35d06c559008118 (patch)
treefab1cc211277bf97fa4d72a017089dc527a69503 /sys/cmd/dwm/util.c
parente39dc38001d230362d1f97f716013e9d22858c04 (diff)
feat: dwm fork
Diffstat (limited to 'sys/cmd/dwm/util.c')
-rw-r--r--sys/cmd/dwm/util.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/sys/cmd/dwm/util.c b/sys/cmd/dwm/util.c
new file mode 100644
index 0000000..c9cc726
--- /dev/null
+++ b/sys/cmd/dwm/util.c
@@ -0,0 +1,34 @@
+/* See LICENSE file for copyright and license details. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void
+fatal(char *fmt, ...) {
+ va_list args;
+
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+
+ if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
+ fputc(' ', stderr);
+ perror(NULL);
+ } else {
+ fputc('\n', stderr);
+ }
+
+ exit(1);
+}
+
+void *
+ecalloc(size_t nmemb, size_t size)
+{
+ void *p;
+
+ if (!(p = calloc(nmemb, size)))
+ fatal("calloc:");
+ return p;
+}
+