Made initialization of slab clearer.

This commit is contained in:
Matthew Parkinson
2019-05-21 15:25:33 +01:00
parent 7de46182a8
commit ef18d7d8d5
4 changed files with 41 additions and 25 deletions

View File

@@ -159,12 +159,9 @@ namespace snmalloc
if ((used & 1) == 1)
return alloc_slab(sizeclass, memory_provider);
auto rsize = sizeclass_to_size(sizeclass);
meta[0].head =
(get_slab_offset(sizeclass, true) + rsize) & (SLAB_SIZE - 1);
meta[0].head = get_initial_bumpptr(sizeclass, true);
meta[0].sizeclass = sizeclass;
meta[0].link = get_slab_offset(sizeclass, true) - 1;
meta[0].link = get_initial_link(sizeclass, true);
if constexpr (decommit_strategy == DecommitAll)
{
@@ -185,11 +182,9 @@ namespace snmalloc
uint8_t n = meta[h].next;
auto rsize = sizeclass_to_size(sizeclass);
meta[h].head =
(get_slab_offset(sizeclass, false) + rsize) & (SLAB_SIZE - 1);
meta[h].head = get_initial_bumpptr(sizeclass, false);
meta[h].sizeclass = sizeclass;
meta[h].link = get_slab_offset(sizeclass, false) - 1;
meta[h].link = get_initial_link(sizeclass, false);
head = h + n + 1;
used += 2;