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>67#include "util.h"89void10die(const char *fmt, ...)11{12 va_list ap;1314 va_start(ap, fmt);15 vfprintf(stderr, fmt, ap);16 va_end(ap);1718 if (fmt[0] && fmt[strlen(fmt)-1] == ':') {19 fputc(' ', stderr);20 perror(NULL);21 } else {22 fputc('\n', stderr);23 }2425 exit(1);26}2728void *29ecalloc(size_t nmemb, size_t size)30{31 void *p;3233 if (!(p = calloc(nmemb, size)))34 die("calloc:");35 return p;36}