summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-08-16 15:01:24 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2019-08-16 15:01:24 -0400
commit54097d6dbd03ee483034dee39f669afd9333aeb1 (patch)
tree2367bab8de52d41f75d5b462e9311a09cb657094 /util
parent1617c304c270996504ac5d285e3b417e3310f97f (diff)
Added identifierS
Diffstat (limited to 'util')
-rw-r--r--util/err.c28
1 files changed, 28 insertions, 0 deletions
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;
+}
+