mirror of
https://github.com/microsoft/mimalloc.git
synced 2024-12-28 22:05:40 +08:00
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`
|
// Uninitialized `calloc`
|
||||||
extern mi_decl_allocator void* mi_heap_mallocn(mi_heap_t* heap, size_t count, size_t size) mi_attr_noexcept {
|
extern mi_decl_allocator void* mi_heap_mallocn(mi_heap_t* heap, size_t count, size_t size) mi_attr_noexcept {
|
||||||
size_t total;
|
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);
|
return mi_heap_malloc(heap, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user