From b02839a6d6327f7f6fec313b355c2c1c18d8be9c Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 22 Mar 2023 11:50:40 +0300 Subject: Move increment of GC_bytes_allocd to GC_alloc_large (refactoring) * include/private/gc_priv.h (GC_alloc_large): Update comment (mention that GC_bytes_allocd is updated too). * malloc.c (GC_alloc_large_and_clear): Likewise. * include/private/gc_priv.h (GC_allocobj): Rename sz argument to gran; update comment. * malloc.c (GC_alloc_large): Increment GC_bytes_allocd (by rounded lb). * malloc.c (GC_generic_malloc_inner): Reformat code; remove lb_adjusted local variable. * malloc.c (GC_generic_malloc_inner_ignore_off_page, GC_generic_malloc_inner, GC_generic_malloc_aligned): Do not update GC_bytes_allocd. * mallocx.c (GC_generic_malloc_ignore_off_page): Likewise. * malloc.c (GC_generic_malloc_inner_ignore_off_page): Remove op and lb_adjusted local variables. * mallocx.c (GC_generic_malloc_ignore_off_page): Remove lb_rounded local variable. --- mallocx.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'mallocx.c') diff --git a/mallocx.c b/mallocx.c index cd0fc527..8dee11b3 100644 --- a/mallocx.c +++ b/mallocx.c @@ -195,7 +195,6 @@ GC_API GC_ATTR_MALLOC void * GC_CALL { void *result; size_t lg; - size_t lb_rounded; word n_blocks; GC_bool init; @@ -203,8 +202,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL return GC_generic_malloc(lb, k); GC_ASSERT(k < MAXOBJKINDS); lg = ROUNDED_UP_GRANULES(lb); - lb_rounded = GRANULES_TO_BYTES(lg); - n_blocks = OBJ_SZ_TO_BLOCKS(lb_rounded); + n_blocks = OBJ_SZ_TO_BLOCKS(GRANULES_TO_BYTES(lg)); init = GC_obj_kinds[k].ok_init; if (EXPECT(get_have_errors(), FALSE)) GC_print_all_errors(); @@ -230,7 +228,6 @@ GC_API GC_ATTR_MALLOC void * GC_CALL ((word *)result)[GRANULES_TO_WORDS(lg)-2] = 0; # endif } - GC_bytes_allocd += lb_rounded; UNLOCK(); if (init && !GC_debugging_started) { BZERO(result, n_blocks * HBLKSIZE); -- cgit v1.2.1