From ed80e5df8c718fc2321904db1b81604d1ed33444 Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 3 May 2025 14:59:49 -0700 Subject: suckless --- config/suckless/dmenu/util.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 config/suckless/dmenu/util.c (limited to 'config/suckless/dmenu/util.c') diff --git a/config/suckless/dmenu/util.c b/config/suckless/dmenu/util.c new file mode 100644 index 0000000..8e26a51 --- /dev/null +++ b/config/suckless/dmenu/util.c @@ -0,0 +1,37 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include +#include + +#include "util.h" + +void +die(const char *fmt, ...) +{ + va_list ap; + int saved_errno; + + saved_errno = errno; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + if (fmt[0] && fmt[strlen(fmt)-1] == ':') + fprintf(stderr, " %s", strerror(saved_errno)); + fputc('\n', stderr); + + exit(1); +} + +void * +ecalloc(size_t nmemb, size_t size) +{ + void *p; + + if (!(p = calloc(nmemb, size))) + die("calloc:"); + return p; +} -- cgit v1.2.3