]> git.armaanb.net Git - dmenu.git/blobdiff - util.c
config.mk: improve feature test check
[dmenu.git] / util.c
diff --git a/util.c b/util.c
index 0e8828cf238072e9bc4cd8641c626c7e1e86074e..9b27512e1efe5fb258b7fa65a07b476fb0bc27fc 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,50 +1,23 @@
-/*
- * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
- * See LICENSE file for license details.
- */
-#include "dmenu.h"
+/* See LICENSE file for copyright and license details. */
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/wait.h>
-#include <unistd.h>
 
-/* static */
-
-static void
-badmalloc(unsigned int size)
-{
-       eprint("fatal: could not malloc() %u bytes\n", size);
-}
-
-/* extern */
-
-void *
-emalloc(unsigned int size)
-{
-       void *res = malloc(size);
-       if(!res)
-               badmalloc(size);
-       return res;
-}
+#include "util.h"
 
 void
-eprint(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);
-}
 
-char *
-estrdup(const char *str)
-{
-       void *res = strdup(str);
-       if(!res)
-               badmalloc(strlen(str));
-       return res;
+       if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
+               fputc(' ', stderr);
+               perror(NULL);
+       }
+
+       exit(1);
 }