[refactor] validate_dyn, pledge, N & n options
[splanner.git] / util.c
blob17f22691e903490bf423be6f833b949044802c37
1 /* See LICENSE file for copyright and license details. */
2 #include <stdarg.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
7 #include "util.h"
9 void *
10 ecalloc(size_t nmemb, size_t size)
12 void *p;
13 p = calloc(nmemb, size);
14 FAIL_IF(p == NULL, "calloc");
15 return p;
18 void
19 die(const char *fmt, ...)
21 va_list ap;
23 va_start(ap, fmt);
24 (void)vfprintf(stderr, fmt, ap);
25 va_end(ap);
27 if (fmt[0] != '\0' && fmt[strlen(fmt)-1] == ':') {
28 (void)fputc(' ', stderr);
29 perror(NULL);
30 } else {
31 (void)fputc('\n', stderr);
34 exit(EXIT_FAILURE);