格式化代码

This commit is contained in:
DreamMaoMao 2025-02-17 13:36:55 +08:00
parent 89b290ebe4
commit 14d9f559d8
6 changed files with 1956 additions and 1916 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;
}