From 54097d6dbd03ee483034dee39f669afd9333aeb1 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Fri, 16 Aug 2019 15:01:24 -0400 Subject: Added identifierS --- util/err.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'util') diff --git a/util/err.c b/util/err.c index 62886c4..7a38017 100644 --- a/util/err.c +++ b/util/err.c @@ -8,3 +8,31 @@ static void err_print(LineNo line, LineNo col, const char *fmt, ...) { vfprintf(stderr, fmt, args); va_end(args); } + +static void *err_malloc(size_t size) { + void *ret = malloc(size); + if (!ret) { + fprintf(stderr, "Error: Out of memory.\n"); + abort(); + } + return ret; +} + +static void *err_calloc(size_t n, size_t size) { + void *ret = calloc(n, size); + if (!ret) { + fprintf(stderr, "Error: Out of memory.\n"); + abort(); + } + return ret; +} + +static void *err_realloc(void *data, size_t new_size) { + void *ret = realloc(data, new_size); + if (!ret) { + fprintf(stderr, "Error: Out of memory.\n"); + abort(); + } + return ret; +} + -- cgit v1.2.3