diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-08-16 15:01:24 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-08-16 15:01:24 -0400 |
commit | 54097d6dbd03ee483034dee39f669afd9333aeb1 (patch) | |
tree | 2367bab8de52d41f75d5b462e9311a09cb657094 /util | |
parent | 1617c304c270996504ac5d285e3b417e3310f97f (diff) |
Added identifierS
Diffstat (limited to 'util')
-rw-r--r-- | util/err.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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; +} + |