summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib.c12
-rw-r--r--lib.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 43d429df..06dc76ff 100644
--- a/lib.c
+++ b/lib.c
@@ -2699,6 +2699,18 @@ mem_t *chk_copy_obj(mem_t *orig, size_t size)
return copy;
}
+mem_t *chk_xalloc(ucnum m, ucnum n, val self)
+{
+ ucnum mn = m * n;
+ size_t size = mn;
+
+ if ((m > 0 && mn / m != n) || (ucnum) size != mn)
+ uw_throwf(error_s, lit("~s: memory allocation size overflow"),
+ self, nao);
+
+ return chk_malloc(size);
+}
+
val cons(val car, val cdr)
{
val obj;
diff --git a/lib.h b/lib.h
index bd5ddff8..ea644448 100644
--- a/lib.h
+++ b/lib.h
@@ -609,6 +609,7 @@ wchar_t *chk_strdup(const wchar_t *str);
char *chk_strdup_utf8(const char *str);
unsigned char *chk_strdup_8bit(const wchar_t *str);
mem_t *chk_copy_obj(mem_t *orig, size_t size);
+mem_t *chk_xalloc(ucnum m, ucnum n, val self);
val cons(val car, val cdr);
val make_lazy_cons(val func);
val make_half_lazy_cons(val func, val car);