Use placement new instead of init for metaslab.

This commit is contained in:
Matthew Parkinson
2019-01-25 19:46:24 +00:00
parent 06ff1ffe0a
commit ec59820970
2 changed files with 4 additions and 9 deletions

View File

@@ -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);

View File

@@ -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