config.def.h: make keys and buttons const
[dwm.git] / util.c
blob96b82c980c4ce304d329fc60e582379ab0400993
1 /* See LICENSE file for copyright and license details. */
2 #include <stdarg.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
7 #include "util.h"
9 void
10 die(const char *fmt, ...)
12 va_list ap;
14 va_start(ap, fmt);
15 vfprintf(stderr, fmt, ap);
16 va_end(ap);
18 if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
19 fputc(' ', stderr);
20 perror(NULL);
21 } else {
22 fputc('\n', stderr);
25 exit(1);
28 void *
29 ecalloc(size_t nmemb, size_t size)
31 void *p;
33 if (!(p = calloc(nmemb, size)))
34 die("calloc:");
35 return p;