opt: format code

fix: correct version message
This commit is contained in:
DreamMaoMao 2025-02-17 13:37:59 +08:00
parent 8ef33dacc0
commit 6287b292fe
7 changed files with 1958 additions and 1918 deletions

37
util.c
View file

@ -6,30 +6,27 @@
#include "util.h"
void
die(const char *fmt, ...) {
va_list ap;
void die(const char *fmt, ...) {
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);
}
void *
ecalloc(size_t nmemb, size_t size)
{
void *p;
void *ecalloc(size_t nmemb, size_t size) {
void *p;
if (!(p = calloc(nmemb, size)))
die("calloc:");
return p;
if (!(p = calloc(nmemb, size)))
die("calloc:");
return p;
}