microsoft / mimalloc

mimalloc is a compact general purpose allocator with excellent performance.
MIT License
10.44k stars 842 forks source link

Misplaced count size #906

Closed Oleksandr-Matasoft closed 3 months ago

Oleksandr-Matasoft commented 3 months ago

In https://github.com/microsoft/mimalloc/blob/08fa864605a3d4d38e4ff4c44f21a72a4ada90c3/src/alloc.c#L532

mi_decl_nodiscard mi_decl_restrict void* mi_new_n(size_t count, size_t size) {
  return mi_heap_alloc_new_n(mi_prim_get_default_heap(), size, count);
}

Or naming is incorrect or it's an argument swap error

Because at definition mi_heap_alloc_new_n(mi_heap_t* heap, size_t count, size_t size) // count goes before size

daanx commented 3 months ago

Yikes -- thanks for spotting this :-). Fortunately, the order does not matter as we calculate count * size for the total allocation size (just checking for overflow), pheew.

Thanks again -- I just fixed it.