summaryrefslogtreecommitdiffstats
path: root/mem.h
diff options
context:
space:
mode:
Diffstat (limited to 'mem.h')
-rw-r--r--mem.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/mem.h b/mem.h
index 2cdb36e..852de0a 100644
--- a/mem.h
+++ b/mem.h
@@ -3,6 +3,7 @@
#include <err.h>
#include <stdlib.h>
+#include <syslog.h>
#define MALLOC(s) xmalloc((s), __FILE__, __LINE__)
#define CALLOC(n, s) xcalloc((n), (s), __FILE__, __LINE__)
@@ -12,8 +13,10 @@ static inline void *xmalloc(size_t s, const char *file, int line)
{
void *p;
- if (!(p = malloc(s)))
- err(1, "%s:%d: malloc", file, line);
+ if (!(p = malloc(s))) {
+ syslog(LOG_ERR, "malloc: %s (line %d)", file, line);
+ exit(1);
+ }
return p;
}
@@ -21,8 +24,10 @@ static inline void *xcalloc(size_t n, size_t s, const char *file, int line)
{
void *p;
- if (!(p = calloc(n, s)))
- err(1, "%s:%d: calloc", file, line);
+ if (!(p = calloc(n, s))) {
+ syslog(LOG_ERR, "calloc: %s (line %d)", file, line);
+ exit(1);
+ }
return p;
}
@@ -30,8 +35,10 @@ static inline void *xrealloc(void *ptr, size_t s, const char *file, int line)
{
void *p;
- if (!(p = realloc(ptr, s)))
- err(1, "%s:%d: realloc", file, line);
+ if (!(p = realloc(ptr, s))) {
+ syslog(LOG_ERR, "realloc: %s (line %d)", file, line);
+ exit(1);
+ }
return p;
}