Fix sizeclass rounding error

This commit is contained in:
Theo Butler
2020-06-06 11:52:50 -04:00
committed by Matthew Parkinson
parent 333190a27d
commit 61afa77898
2 changed files with 42 additions and 21 deletions

View File

@@ -188,10 +188,14 @@ namespace snmalloc
SNMALLOC_FAST_PATH static size_t round_size(size_t size)
{
if (size > size_to_sizeclass(NUM_SIZECLASSES - 1))
if (size > sizeclass_to_size(NUM_SIZECLASSES - 1))
{
return bits::next_pow2(size);
}
if (size == 0)
{
size = 1;
}
return sizeclass_to_size(size_to_sizeclass(size));
}
} // namespace snmalloc