From d93875239734b39fc840c468fbb620551186468c Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 23 Feb 2022 18:12:56 +0300 Subject: Roundup size passed to GC_expand_hp GC_expand_hp_inner accepts size in blocks; previously the size in bytes was rounded down when converted to blocks in GC_expand_hp. * alloc.c (GC_expand_hp): Declare n_blocks local variable and set its value to OBJ_SZ_TO_BLOCKS_CHECKED(bytes); change type of result local variable from int to GC_bool; pass n_blocks to GC_expand_hp_inner. --- alloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'alloc.c') diff --git a/alloc.c b/alloc.c index f7285b95..632213df 100644 --- a/alloc.c +++ b/alloc.c @@ -1601,15 +1601,16 @@ GC_INNER GC_bool GC_expand_hp_inner(word n) /* The argument is in bytes. Includes GC_init() call. */ GC_API int GC_CALL GC_expand_hp(size_t bytes) { - int result; + word n_blocks = OBJ_SZ_TO_BLOCKS_CHECKED(bytes); + GC_bool result; DCL_LOCK_STATE; if (!EXPECT(GC_is_initialized, TRUE)) GC_init(); LOCK(); - result = (int)GC_expand_hp_inner(divHBLKSZ((word)bytes)); + result = GC_expand_hp_inner(n_blocks); if (result) GC_requested_heapsize += bytes; UNLOCK(); - return(result); + return (int)result; } GC_INNER unsigned GC_fail_count = 0; -- cgit v1.2.1