From 67b9608ccf87aa69cccd11a6960874ef60b48ced Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Mon, 27 Aug 2018 09:21:42 -0400 Subject: [PATCH] avoid duplicated init code calculating slab size --- malloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/malloc.c b/malloc.c index eb50f4f..fef6185 100644 --- a/malloc.c +++ b/malloc.c @@ -637,9 +637,9 @@ COLD static void init_slow_path(void) { size = 16; } c->size_divisor = libdivide_u32_gen(size); - c->slab_size_divisor = libdivide_u64_gen(get_slab_size(size_class_slots[i], size)); - size_t slots = size_class_slots[i]; - size_t metadata_max = get_metadata_max(get_slab_size(slots, size)); + size_t slab_size = get_slab_size(size_class_slots[i], size); + c->slab_size_divisor = libdivide_u64_gen(slab_size); + size_t metadata_max = get_metadata_max(slab_size); c->slab_info = allocate_pages(metadata_max * sizeof(struct slab_metadata), PAGE_SIZE, false); if (c->slab_info == NULL) { fatal_error("failed to allocate slab metadata");