summaryrefslogtreecommitdiff
path: root/fitz/base_memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'fitz/base_memory.c')
-rw-r--r--fitz/base_memory.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/fitz/base_memory.c b/fitz/base_memory.c
index 27474cc3..cf972542 100644
--- a/fitz/base_memory.c
+++ b/fitz/base_memory.c
@@ -36,6 +36,29 @@ fz_malloc_array(fz_context *ctx, unsigned int count, unsigned int size)
}
void *
+fz_calloc(fz_context *ctx, unsigned int count, unsigned int size)
+{
+ void *p;
+
+ if (count == 0 || size == 0)
+ return 0;
+
+ if (count > UINT_MAX / size)
+ {
+ fprintf(stderr, "fatal error: out of memory (integer overflow)\n");
+ abort();
+ }
+
+ p = calloc(count, size);
+ if (!p)
+ {
+ fprintf(stderr, "fatal error: out of memory\n");
+ abort();
+ }
+ return p;
+}
+
+void *
fz_resize_array(fz_context *ctx, void *p, unsigned int count, unsigned int size)
{
void *np;