summaryrefslogtreecommitdiff
path: root/alloc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-02-23 18:12:56 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-02-23 18:12:56 +0300
commitd93875239734b39fc840c468fbb620551186468c (patch)
treed001dd61959fefd499be2fc8ff98908e53279dca /alloc.c
parent70f9e78d289a4a757093dc48ca6d08ca1b174f81 (diff)
downloadbdwgc-d93875239734b39fc840c468fbb620551186468c.tar.gz
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.
Diffstat (limited to 'alloc.c')
-rw-r--r--alloc.c7
1 files changed, 4 insertions, 3 deletions
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;