specialize mi_mallocn for count=1
This commit is contained in:
parent
8d8f355ed0
commit
4e91eab8fc
@ -443,7 +443,12 @@ mi_decl_allocator void* mi_calloc(size_t count, size_t size) mi_attr_noexcept {
|
||||
// Uninitialized `calloc`
|
||||
extern mi_decl_allocator void* mi_heap_mallocn(mi_heap_t* heap, size_t count, size_t size) mi_attr_noexcept {
|
||||
size_t total;
|
||||
if (mi_mul_overflow(count,size,&total)) return NULL;
|
||||
if (count==1) {
|
||||
total = size;
|
||||
}
|
||||
else if (mi_mul_overflow(count, size, &total)) {
|
||||
return NULL;
|
||||
}
|
||||
return mi_heap_malloc(heap, total);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user