dotfiles

my shiny new dotfiles
git clone git://git.jakekoroman.com/dotfiles
Log | Files | Refs | README

util.c (521B)


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