From aa0a43277b7b26fdd5f80e4e0a28142d6a93068c Mon Sep 17 00:00:00 2001 From: Bradley Taunt Date: Thu, 18 Jan 2024 12:45:24 -0500 Subject: Initial commit on the self-hosted cgit platform --- util.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 util.c (limited to 'util.c') diff --git a/util.c b/util.c new file mode 100755 index 0000000..96b82c9 --- /dev/null +++ b/util.c @@ -0,0 +1,36 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include + +#include "util.h" + +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); + } else { + fputc('\n', stderr); + } + + exit(1); +} + +void * +ecalloc(size_t nmemb, size_t size) +{ + void *p; + + if (!(p = calloc(nmemb, size))) + die("calloc:"); + return p; +} -- cgit v1.2.3-54-g00ecf