aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Barnes <craigbarnes@protonmail.com>2020-08-05 19:11:51 +0000
committerCraig Barnes <craigbarnes@protonmail.com>2020-08-05 19:11:51 +0000
commit014019e98da7fa0f7476bea5b6f3c84dafe7558a (patch)
tree5ba24f69d383378a9a3fe86c8d83cbead89f19c1
parentconfig: handle allocation failure explicitly (diff)
xmalloc: log error to syslog() in fatal_error() function
-rw-r--r--xmalloc.c3
-rw-r--r--xmalloc.h1
2 files changed, 3 insertions, 1 deletions
diff --git a/xmalloc.c b/xmalloc.c
index aecb5787..7322953a 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -2,11 +2,14 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
#include "xmalloc.h"
static NORETURN COLD void
fatal_error(const char *msg, int err)
{
+ syslog(LOG_ERR, "%s: %s", msg, strerror(err));
errno = err;
perror(msg);
abort();
diff --git a/xmalloc.h b/xmalloc.h
index d4e48f79..90d63031 100644
--- a/xmalloc.h
+++ b/xmalloc.h
@@ -1,7 +1,6 @@
#pragma once
#include <stddef.h>
-#include <string.h>
#include "macros.h"
void *xmalloc(size_t size) XMALLOC;