diff --git a/src/mem/alloc.h b/src/mem/alloc.h index 23680f2..73a5844 100644 --- a/src/mem/alloc.h +++ b/src/mem/alloc.h @@ -922,8 +922,9 @@ namespace snmalloc if (super != nullptr) return super; - super = reinterpret_cast( - large_allocator.template alloc(0, SUPERSLAB_SIZE)); + super = + reinterpret_cast(large_allocator.template alloc( + 0, SUPERSLAB_SIZE, SUPERSLAB_SIZE)); if (super == nullptr) return super; @@ -1304,8 +1305,9 @@ namespace snmalloc sizeclass, rsize, size); }); } - slab = reinterpret_cast( - large_allocator.template alloc(0, SUPERSLAB_SIZE)); + slab = + reinterpret_cast(large_allocator.template alloc( + 0, SUPERSLAB_SIZE, SUPERSLAB_SIZE)); if (slab == nullptr) return nullptr; @@ -1413,7 +1415,13 @@ namespace snmalloc size_t large_class = size_bits - SUPERSLAB_BITS; SNMALLOC_ASSERT(large_class < NUM_LARGE_CLASSES); - void* p = large_allocator.template alloc(large_class, size); + size_t rsize = bits::one_at_bit(SUPERSLAB_BITS) << large_class; + // For superslab size, we always commit the whole range. + if (large_class == 0) + size = rsize; + + void* p = + large_allocator.template alloc(large_class, rsize, size); if (likely(p != nullptr)) { chunkmap().set_large_size(p, size); diff --git a/src/mem/largealloc.h b/src/mem/largealloc.h index 1343300..ace16d0 100644 --- a/src/mem/largealloc.h +++ b/src/mem/largealloc.h @@ -290,12 +290,10 @@ namespace snmalloc LargeAlloc(MemoryProvider& mp) : memory_provider(mp) {} template - void* alloc(size_t large_class, size_t size) + void* alloc(size_t large_class, size_t rsize, size_t size) { - size_t rsize = bits::one_at_bit(SUPERSLAB_BITS) << large_class; - // For superslab size, we always commit the whole range. - if (large_class == 0) - size = rsize; + SNMALLOC_ASSERT( + (bits::one_at_bit(SUPERSLAB_BITS) << large_class) == rsize); void* p = memory_provider.pop_large_stack(large_class);