The union in Metaslab provides no benefit in size, as the single byte
it effectively saves will be removed due to padding.

By removing the union, we get stronger properties over sizeclass, and
remove an out-of-bounds access.
This commit is contained in:
Matthew Parkinson 2019-01-18 21:09:55 +00:00
Родитель dc19b5ace2
Коммит 94f8b886a0
2 изменённых файлов: 3 добавлений и 5 удалений

Просмотреть файл

@ -57,11 +57,8 @@ namespace snmalloc
// doubly linked node into that size class's free list.
uint16_t link;
union
{
uint8_t sizeclass;
uint8_t next;
};
uint8_t sizeclass;
uint8_t next;
void add_use()
{

Просмотреть файл

@ -194,6 +194,7 @@ namespace snmalloc
uint8_t index = (uint8_t)slab_to_index(slab);
uint8_t n = head - index - 1;
meta[index].sizeclass = 0;
meta[index].next = n;
head = index;
bool was_almost_full = is_almost_full();