Use placement new instead of init for metaslab.
This commit is contained in:
@@ -34,7 +34,7 @@ namespace snmalloc
|
||||
{
|
||||
private:
|
||||
// How many entries are used in this slab.
|
||||
uint16_t used;
|
||||
uint16_t used = 0;
|
||||
|
||||
public:
|
||||
// Bump free list of unused entries in this sizeclass.
|
||||
@@ -59,7 +59,8 @@ namespace snmalloc
|
||||
Mod<SLAB_SIZE, uint16_t> link;
|
||||
|
||||
uint8_t sizeclass;
|
||||
uint8_t next;
|
||||
// Initially zero to encode the superslabs relative list of slabs.
|
||||
uint8_t next = 0;
|
||||
|
||||
void add_use()
|
||||
{
|
||||
@@ -92,12 +93,6 @@ namespace snmalloc
|
||||
head = (uint16_t)~0;
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
used = 0;
|
||||
next = 0;
|
||||
}
|
||||
|
||||
SlabLink* get_link(Slab* slab)
|
||||
{
|
||||
return (SlabLink*)((size_t)slab + link);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace snmalloc
|
||||
used = 0;
|
||||
for (size_t i = 0; i < SLAB_COUNT; i++)
|
||||
{
|
||||
meta[i].init();
|
||||
new (&(meta[i])) Metaslab();
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
|
||||
Reference in New Issue
Block a user