From 484e1e33da7477b7278c9a3e9da878f0375dd75b Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 17 Dec 2020 16:27:23 -0800 Subject: Memory allocation failure checks, and a simpler new() function --- utils.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'utils.c') diff --git a/utils.c b/utils.c index 2cc5258..16a53a3 100644 --- a/utils.c +++ b/utils.c @@ -172,5 +172,13 @@ size_t unescape_string(char *dest, const char *src, size_t bufsize) #undef PUT } +void *memcheck(void *p) +{ + if (p == NULL) { + fprintf(stderr, "memory allocation failure\n"); + _exit(1); + } + return p; +} // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1 -- cgit v1.2.3