diff options
| author | Lignum Crucis | 2026-03-24 22:16:06 -0300 |
|---|---|---|
| committer | Lignum Crucis | 2026-03-24 22:18:41 -0300 |
| commit | 4a4275bac6b4a7dc5131f7bc04e3c8447c5931e4 (patch) | |
| tree | 3b922f52f161c1d6b86b2ba2892bddcc5c2017b5 /util.c | |
initial commit
basic configuration and restartsig patch
Diffstat (limited to 'util.c')
| -rw-r--r-- | util.c | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ +/* See LICENSE file for copyright and license details. */ +#include <errno.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "util.h" + +void +die(const char *fmt, ...) +{ + va_list ap; + int saved_errno; + + saved_errno = errno; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + if (fmt[0] && fmt[strlen(fmt)-1] == ':') + fprintf(stderr, " %s", strerror(saved_errno)); + fputc('\n', stderr); + + exit(1); +} + +void * +ecalloc(size_t nmemb, size_t size) +{ + void *p; + + if (!(p = calloc(nmemb, size))) + die("calloc:"); + return p; +} |
