diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2023-04-10 23:41:17 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2023-04-10 23:56:12 +0300 |
commit | f62ced2173e0d665a1797acf85568ee030aa64f2 (patch) | |
tree | dc65821b0d91cc80fb5a75647e2f60d6b9c36bc2 /mallocx.c | |
parent | 592873e05259ac81e93b3ed0b787279b9f993a7f (diff) | |
download | bdwgc-f62ced2173e0d665a1797acf85568ee030aa64f2.tar.gz |
Eliminate duplicate use of GC_obj_kinds[k] in GC_generic_malloc_many
(refactoring)
* mallocx.c (GC_generic_malloc_many): Move assignment of ok local
variable down to the place just before use; use ok instead of getting
value of GC_obj_kinds[k] once more.
Diffstat (limited to 'mallocx.c')
-rw-r--r-- | mallocx.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -260,7 +260,7 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t lb, int k, void **result) size_t lw; /* Length in words. */ size_t lg; /* Length in granules. */ signed_word my_bytes_allocd = 0; - struct obj_kind * ok = &(GC_obj_kinds[k]); + struct obj_kind * ok; struct hblk ** rlh; GC_ASSERT(lb != 0 && (lb & (GRANULE_BYTES-1)) == 0); @@ -297,6 +297,7 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t lb, int k, void **result) } /* First see if we can reclaim a page of objects waiting to be */ /* reclaimed. */ + ok = &GC_obj_kinds[k]; rlh = ok -> ok_reclaim_list; if (rlh != NULL) { struct hblk * hbp; @@ -378,8 +379,8 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t lb, int k, void **result) /* Next try to use prefix of global free list if there is one. */ /* We don't refill it, but we need to use it up before allocating */ /* a new block ourselves. */ - opp = &(GC_obj_kinds[k].ok_freelist[lg]); - if ( (op = *opp) != 0 ) { + opp = &(ok -> ok_freelist[lg]); + if ((op = *opp) != NULL) { *opp = 0; my_bytes_allocd = 0; for (p = op; p != 0; p = obj_link(p)) { |