aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2015-10-20 23:34:49 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2015-10-20 23:38:31 +0200
commit646b351cc79845f4cc77415dfff474b9ae0053d9 (patch)
treed3de639691f7f845a705007e93560160d3b3ee5c /util.c
parente3b7e1d620e18818222c1e5033356ae29dd49e7f (diff)
downloaddwm-646b351cc79845f4cc77415dfff474b9ae0053d9.tar.gz
sync updated drw code from dmenu
important: - drw_rect: didn't use w and h, change the dwm code accordingly. - drw_text: text is NULL is not allowed, use drw_rect().
Diffstat (limited to 'util.c')
-rw-r--r--util.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/util.c b/util.c
index 51acd1a..6b703e9 100644
--- a/util.c
+++ b/util.c
@@ -2,16 +2,32 @@
#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 *errstr, ...) {
+die(const char *fmt, ...) {
va_list ap;
- va_start(ap, errstr);
- vfprintf(stderr, errstr, ap);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
va_end(ap);
- exit(EXIT_FAILURE);
-}
+ if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
+ fputc(' ', stderr);
+ perror(NULL);
+ }
+
+ exit(1);
+}