From 2169a4155362a7f1639e4ad78033abb193f2d565 Mon Sep 17 00:00:00 2001 From: Luca Matei Pintilie Date: Tue, 21 Dec 2021 21:22:43 +0100 Subject: Initial commit --- dwm/chadwm/util.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 dwm/chadwm/util.c (limited to 'dwm/chadwm/util.c') 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 +#include +#include +#include + +#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); +} -- cgit v1.2.3