Handle 2^16 slabs

This code assumes that 16bit uint wrapping can be used, rather than
masking by SLAB_SIZE-1.  Add explicit mask, so we can change the
SLAB_SIZE to be smaller.
This commit is contained in:
Matthew Parkinson
2019-01-17 14:05:38 +00:00
parent cf8699df4f
commit b097b47aa2

View File

@@ -58,7 +58,7 @@ namespace snmalloc
{
// This slab is being bump allocated.
p = (void*)((size_t)this + head - 1);
meta->head = head + (uint16_t)rsize;
meta->head = (head + (uint16_t)rsize) & (SLAB_SIZE - 1);
if (meta->head == 1)
{
meta->set_full();