diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2026-08-18 17:45:10 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2026-08-18 17:45:10 +0800 |
| commit | 82680bc3350807c532d0aeb714cb5360da9293f0 (patch) | |
| tree | c34a1965430d6019e45fc184cb6d3a86bc1ccd50 /mem.h | |
| parent | 75db6d795d689e28560aa7e6b3d471c89983191a (diff) | |
| download | lex-82680bc3350807c532d0aeb714cb5360da9293f0.tar.gz | |
Use syslog, move the sock to dexd subdirectory.
Diffstat (limited to 'mem.h')
| -rw-r--r-- | mem.h | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -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; } |
