summaryrefslogtreecommitdiff
path: root/linker/linker_memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linker/linker_memory.cpp')
-rw-r--r--linker/linker_memory.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/linker/linker_memory.cpp b/linker/linker_memory.cpp
index 6a54c138f..f2cce01d9 100644
--- a/linker/linker_memory.cpp
+++ b/linker/linker_memory.cpp
@@ -80,7 +80,15 @@ void* realloc(void* p, size_t byte_count) {
return get_allocator().realloc(p, byte_count);
}
+void* reallocarray(void* p, size_t item_count, size_t item_size) {
+ size_t byte_count;
+ if (__builtin_mul_overflow(item_count, item_size, &byte_count)) {
+ errno = ENOMEM;
+ return nullptr;
+ }
+ return get_allocator().realloc(p, byte_count);
+}
+
void free(void* ptr) {
get_allocator().free(ptr);
}
-