aboutsummaryrefslogtreecommitdiff
path: root/dwm/chadwm/util.c
diff options
context:
space:
mode:
authorLuca Matei Pintilie <lucafulger@gmail.com>2021-12-21 20:22:43 +0000
committerLuca Matei Pintilie <lucafulger@gmail.com>2021-12-21 20:22:43 +0000
commit2169a4155362a7f1639e4ad78033abb193f2d565 (patch)
tree463b62f77e90862496fcab792a45c5d21f4d73fc /dwm/chadwm/util.c
downloaddotfiles-2169a4155362a7f1639e4ad78033abb193f2d565.tar
dotfiles-2169a4155362a7f1639e4ad78033abb193f2d565.tar.gz
dotfiles-2169a4155362a7f1639e4ad78033abb193f2d565.tar.bz2
dotfiles-2169a4155362a7f1639e4ad78033abb193f2d565.tar.lz
dotfiles-2169a4155362a7f1639e4ad78033abb193f2d565.tar.xz
dotfiles-2169a4155362a7f1639e4ad78033abb193f2d565.tar.zst
dotfiles-2169a4155362a7f1639e4ad78033abb193f2d565.zip
Initial commit
Diffstat (limited to 'dwm/chadwm/util.c')
-rw-r--r--dwm/chadwm/util.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/dwm/chadwm/util.c b/dwm/chadwm/util.c
new file mode 100644
index 0000000..7a76441
--- /dev/null
+++ b/dwm/chadwm/util.c
@@ -0,0 +1,37 @@
+/* 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)))
+ die("calloc:");
+ 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);
+ }
+ else {
+ fputc('\n', stderr);
+ }
+
+ exit(1);
+}