From 08911c9f247d385a446ebff75253c407936553cd Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 18 Jan 2023 08:15:52 +0300 Subject: Remove unneeded n_blocks local variable in malloc.c and reclaim.c (refactoring) * malloc.c (GC_alloc_large_and_clear): Remove n_blocks local variable. * malloc.c (GC_generic_malloc): Likewise. * reclaim.c [ENABLE_DISCLAIM] (GC_disclaim_and_reclaim): Replace (*proc)() to proc(). * reclaim.c [ENABLE_DISCLAIM] (GC_reclaim_block): Likewise. * reclaim.c (GC_reclaim_block): Remove blocks local variable. --- malloc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'malloc.c') diff --git a/malloc.c b/malloc.c index 8d3fae06..dc72a62d 100644 --- a/malloc.c +++ b/malloc.c @@ -94,10 +94,8 @@ STATIC ptr_t GC_alloc_large_and_clear(size_t lb, int k, unsigned flags) result = GC_alloc_large(lb, k, flags); if (result != NULL && (GC_debugging_started || GC_obj_kinds[k].ok_init)) { - word n_blocks = OBJ_SZ_TO_BLOCKS(lb); - /* Clear the whole block, in case of GC_realloc call. */ - BZERO(result, n_blocks * HBLKSIZE); + BZERO(result, HBLKSIZE * OBJ_SZ_TO_BLOCKS(lb)); } return result; } @@ -258,18 +256,16 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_generic_malloc(size_t lb, int k) } else { size_t lg; size_t lb_rounded; - word n_blocks; GC_bool init; lg = ROUNDED_UP_GRANULES(lb); lb_rounded = GRANULES_TO_BYTES(lg); - n_blocks = OBJ_SZ_TO_BLOCKS(lb_rounded); init = GC_obj_kinds[k].ok_init; LOCK(); result = (ptr_t)GC_alloc_large(lb_rounded, k, 0); if (0 != result) { if (GC_debugging_started) { - BZERO(result, n_blocks * HBLKSIZE); + BZERO(result, HBLKSIZE * OBJ_SZ_TO_BLOCKS(lb_rounded)); } else { # ifdef THREADS /* Clear any memory that might be used for GC descriptors */ @@ -284,7 +280,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_generic_malloc(size_t lb, int k) } UNLOCK(); if (init && !GC_debugging_started && 0 != result) { - BZERO(result, n_blocks * HBLKSIZE); + BZERO(result, HBLKSIZE * OBJ_SZ_TO_BLOCKS(lb_rounded)); } } if (EXPECT(NULL == result, FALSE)) return (*GC_get_oom_fn())(lb); -- cgit v1.2.1