diff options
author | Julian T <julian@T410.mynet> | 2018-09-05 21:26:17 +0200 |
---|---|---|
committer | Julian T <julian@T410.mynet> | 2018-09-05 21:26:17 +0200 |
commit | c65cccf6c83150736d4ad7edfa15a0fc6994ff14 (patch) | |
tree | 091f73717f14c4b6c4a780029242b89a0abd9b00 /util.c |
Added source
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -0,0 +1,33 @@ +/* See LICENSE file for copyright and license details. */ +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "util.h" + +void * +ecalloc(size_t nmemb, size_t size) +{ + void *p; + + 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); +} |