diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2023-01-18 08:15:52 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2023-01-18 09:36:53 +0300 |
commit | 08911c9f247d385a446ebff75253c407936553cd (patch) | |
tree | 23201eb3310c35d903fc4802a13a4121b289de93 /malloc.c | |
parent | 6ed8630b91f1d21598a069db6bbb7a072bc44915 (diff) | |
download | bdwgc-08911c9f247d385a446ebff75253c407936553cd.tar.gz |
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.
Diffstat (limited to 'malloc.c')
-rw-r--r-- | malloc.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -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); |