This commit is contained in:
Luca Bilke 2023-01-10 12:51:51 +01:00
commit c0c0adc645
No known key found for this signature in database
GPG key ID: 7B77C51E8C779E75
7 changed files with 1283 additions and 1279 deletions

30
util.c
View file

@ -9,27 +9,27 @@
void *
ecalloc(size_t nmemb, size_t size)
{
void *p;
void *p;
if (!(p = calloc(nmemb, size)))
die("calloc:");
return p;
if (!(p = calloc(nmemb, size)))
die("calloc:");
return p;
}
void
die(const char *fmt, ...) {
va_list ap;
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(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);
}
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
fputc(' ', stderr);
perror(NULL);
} else {
fputc('\n', stderr);
}
exit(1);
exit(1);
}