From 41fb89517ab13a4530b13f7e0f635ef4021364a1 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 17 Sep 2020 16:09:45 -0400 Subject: [PATCH] simplify malloc_info code --- h_malloc.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/h_malloc.c b/h_malloc.c index 479ec4c..b8b7c12 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -1808,16 +1808,11 @@ EXPORT int h_malloc_info(int options, UNUSED FILE *fp) { for (unsigned class = 0; class < N_SIZE_CLASSES; class++) { struct size_class *c = &ro.size_class_metadata[arena][class]; - u64 nmalloc; - u64 ndalloc; - size_t slab_allocated; - size_t allocated; - mutex_lock(&c->lock); - nmalloc = c->nmalloc; - ndalloc = c->ndalloc; - slab_allocated = c->slab_allocated; - allocated = c->allocated; + u64 nmalloc = c->nmalloc; + u64 ndalloc = c->ndalloc; + size_t slab_allocated = c->slab_allocated; + size_t allocated = c->allocated; mutex_unlock(&c->lock); if (nmalloc || ndalloc || slab_allocated || allocated) { @@ -1833,11 +1828,9 @@ EXPORT int h_malloc_info(int options, UNUSED FILE *fp) { fputs("", fp); } - size_t region_allocated; - struct region_allocator *ra = ro.region_allocator; mutex_lock(&ra->lock); - region_allocated = ra->allocated; + size_t region_allocated = ra->allocated; mutex_unlock(&ra->lock); fprintf(fp, "", N_ARENA);