dwm

Kris's build of dwm
git clone git clone https://git.krisyotam.com/krisyotam/dwm.git
Log | Files | Refs | README | LICENSE

util.c (571B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <errno.h>
      3 #include <stdarg.h>
      4 #include <stdio.h>
      5 #include <stdlib.h>
      6 #include <string.h>
      7 
      8 #include "util.h"
      9 
     10 void
     11 die(const char *fmt, ...)
     12 {
     13 	va_list ap;
     14 	int saved_errno;
     15 
     16 	saved_errno = errno;
     17 	va_start(ap, fmt);
     18 	vfprintf(stderr, fmt, ap);
     19 	va_end(ap);
     20 
     21 	if (fmt[0] && fmt[strlen(fmt)-1] == ':')
     22 		fprintf(stderr, " %s", strerror(saved_errno));
     23 	fputc('\n', stderr);
     24 
     25 	exit(1);
     26 }
     27 
     28 void *
     29 ecalloc(size_t nmemb, size_t size)
     30 {
     31 	void *p;
     32 
     33 	if (!(p = calloc(nmemb, size)))
     34 		die("calloc:");
     35 	return p;
     36 }