From 7251022e24fb9cb350a5d57f78cd169b0a045c73 Mon Sep 17 00:00:00 2001 From: Nathaniel Filardo Date: Tue, 14 May 2019 14:07:08 +0100 Subject: [PATCH] superslab: reorder initialization Setting kind and then immediately testing it seems wrong. --- src/mem/superslab.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mem/superslab.h b/src/mem/superslab.h index 1e9fc4e..c77e57f 100644 --- a/src/mem/superslab.h +++ b/src/mem/superslab.h @@ -82,12 +82,6 @@ namespace snmalloc if (kind != Super) { - // If this wasn't previously a Superslab, we need to set up the - // header. - kind = Super; - // Point head at the first non-short slab. - head = 1; - if (kind != Fresh) { // If this wasn't previously Fresh, we need to zero some things. @@ -97,6 +91,13 @@ namespace snmalloc new (&(meta[i])) Metaslab(); } } + + // If this wasn't previously a Superslab, we need to set up the + // header. + kind = Super; + // Point head at the first non-short slab. + head = 1; + #ifndef NDEBUG auto curr = head; for (size_t i = 0; i < SLAB_COUNT - used - 1; i++)