import new drw and util from libsl.

This commit is contained in:
Markus Teich
2016-05-21 21:39:58 +02:00
parent 268d1968ea
commit 27a904c1dd
6 changed files with 238 additions and 240 deletions

30
util.c
View File

@ -2,16 +2,32 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "util.h"
void
die(const char *errstr, ...) {
va_list ap;
void *
ecalloc(size_t nmemb, size_t size)
{
void *p;
va_start(ap, errstr);
vfprintf(stderr, errstr, ap);
va_end(ap);
exit(1);
if (!(p = calloc(nmemb, size)))
perror(NULL);
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);
}
exit(1);
}