summaryrefslogtreecommitdiffstats
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
parentdwm: use ecalloc, prevent theoretical overflow (diff)
downloaddwm-646b351cc79845f4cc77415dfff474b9ae0053d9.tar.gz
dwm-646b351cc79845f4cc77415dfff474b9ae0053d9.zip
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 '')
-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 @@
2#include <stdarg.h> 2#include <stdarg.h>
3#include <stdio.h> 3#include <stdio.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#include <string.h>
5 6
6#include "util.h" 7#include "util.h"
7 8
9void *
10ecalloc(size_t nmemb, size_t size)
11{
12 void *p;
13
14 if (!(p = calloc(nmemb, size)))
15 perror(NULL);
16 return p;
17}
18
8void 19void
9die(const char *errstr, ...) { 20die(const char *fmt, ...) {
10 va_list ap; 21 va_list ap;
11 22
12 va_start(ap, errstr); 23 va_start(ap, fmt);
13 vfprintf(stderr, errstr, ap); 24 vfprintf(stderr, fmt, ap);
14 va_end(ap); 25 va_end(ap);
15 exit(EXIT_FAILURE);
16}
17 26
27 if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
28 fputc(' ', stderr);
29 perror(NULL);
30 }
31
32 exit(1);
33}