summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-04-25 07:47:53 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-04-25 07:47:53 +0300
commit72191d191fb4272b8e626c4db7763023d41d7f88 (patch)
tree9d82ff22bc5a60bed0cca1c6026b7e266ef1204f
parent44835b9b4b73bc673b7688bbaa81596a0272070c (diff)
downloadbdwgc-72191d191fb4272b8e626c4db7763023d41d7f88.tar.gz
Remove extra variable and rename argument of GC_new_hblk
(refactoring) * new_hblk.c (GC_new_hblk): Reformat comment; rename kind argument to k one; remove clear local variable.
-rw-r--r--new_hblk.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/new_hblk.c b/new_hblk.c
index b8b06682..c5a29ad2 100644
--- a/new_hblk.c
+++ b/new_hblk.c
@@ -162,29 +162,27 @@ GC_INNER ptr_t GC_build_fl(struct hblk *h, size_t sz, GC_bool clear,
return (ptr_t)p;
}
-/* Allocate a new heapblock for small objects of size gran granules. */
-/* Add all of the heapblock's objects to the free list for objects */
-/* of that size. Set all mark bits if objects are uncollectible. */
-/* Will fail to do anything if we are out of memory. */
-GC_INNER void GC_new_hblk(size_t gran, int kind)
+/* Allocate a new heapblock for small objects of the given size in */
+/* granules and kind. Add all of the heapblock's objects to the */
+/* free list for objects of that size. Set all mark bits */
+/* if objects are uncollectible. Will fail to do anything if we */
+/* are out of memory. */
+GC_INNER void GC_new_hblk(size_t gran, int k)
{
struct hblk *h; /* the new heap block */
- GC_bool clear = GC_obj_kinds[kind].ok_init;
GC_STATIC_ASSERT((sizeof (struct hblk)) == HBLKSIZE);
GC_ASSERT(I_HOLD_LOCK());
-
- if (GC_debugging_started) clear = TRUE;
-
- /* Allocate a new heap block */
- h = GC_allochblk(GRANULES_TO_BYTES(gran), kind, 0 /* flags */, 0);
- if (EXPECT(NULL == h, FALSE)) return;
+ /* Allocate a new heap block. */
+ h = GC_allochblk(GRANULES_TO_BYTES(gran), k, 0 /* flags */, 0);
+ if (EXPECT(NULL == h, FALSE)) return; /* out of memory */
/* Mark all objects if appropriate. */
- if (IS_UNCOLLECTABLE(kind)) GC_set_hdr_marks(HDR(h));
+ if (IS_UNCOLLECTABLE(k)) GC_set_hdr_marks(HDR(h));
/* Build the free list */
- GC_obj_kinds[kind].ok_freelist[gran] =
- GC_build_fl(h, GRANULES_TO_WORDS(gran), clear,
- (ptr_t)GC_obj_kinds[kind].ok_freelist[gran]);
+ GC_obj_kinds[k].ok_freelist[gran] =
+ GC_build_fl(h, GRANULES_TO_WORDS(gran),
+ GC_debugging_started || GC_obj_kinds[k].ok_init,
+ (ptr_t)GC_obj_kinds[k].ok_freelist[gran]);
}