dwl-mod/util.c

36 行
540 B
C
Raw 通常表示 履歴

/* See LICENSE.dwm file for copyright and license details. */
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "util.h"
void
die(const char *fmt, ...) {
2023-08-27 13:33:54 +09:00
va_list ap;
2023-08-27 13:33:54 +09:00
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
2023-08-27 13:33:54 +09:00
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
fputc(' ', stderr);
perror(NULL);
} else {
fputc('\n', stderr);
}
2023-08-27 13:33:54 +09:00
exit(1);
}
2022-10-30 04:55:03 +09:00
void *
ecalloc(size_t nmemb, size_t size)
{
2023-08-27 13:33:54 +09:00
void *p;
2022-10-30 04:55:03 +09:00
2023-08-27 13:33:54 +09:00
if (!(p = calloc(nmemb, size)))
die("calloc:");
return p;
2022-10-30 04:55:03 +09:00
}