diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2023-01-20 09:37:48 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2023-01-20 10:01:51 +0300 |
commit | 3dbb260e5f277a350da7251e01dd3284f973f36f (patch) | |
tree | da3e650af5c613a3ba48e3f9b2f1a8d2a8d62556 /alloc.c | |
parent | 08911c9f247d385a446ebff75253c407936553cd (diff) | |
download | bdwgc-3dbb260e5f277a350da7251e01dd3284f973f36f.tar.gz |
Simplify code of GC_allochblk_nth
(refactoring)
Issue #510 (bdwgc).
* allchblk.c (GC_hblk_fl_from_blocks): Change type of blocks argument
from word to size_t.
* allchblk.c (setup_header): Reformat comment.
* allchblk.c (GC_get_first_part): Change type of total_size local
variable from word to size_t; add assertion that bytes argument is
multiple of HBLKSIZE.
* allchblk.c (GC_get_first_part): Specify that result of
GC_install_header() is unlikely to be NULL.
* alloc.c (GC_add_to_heap): Likewise.
* allchblk.c (AVOID_SPLIT_REMAPPED): Define only if USE_MUNMAP.
* allchblk.c (GC_allochblk): Remove comment; change blocks*HBLKSIZE<0
to blocks>=GC_SIZE_MAX/(2*HBLKSIZE) and expect its result unlikely to
be true.
* allchblk.c (GC_allochblk): Vhange type of blocks local variable from
word to size_t.
* malloc.c (GC_alloc_large): Likewise.
* allchblk.c (GC_drop_blacklisted_count): New STATIC varible (replaces\
count static one in GC_allochblk_nth).
* allchblk.c (next_hblk_fits_better, find_nonbl_hblk,
drop_hblk_in_chunks): New static function (move code GC_allochblk_nth).
* allchblk.c (GC_allochblk_nth): Refine comment; add assertion that
sz is non-zero; change type of size_needed and size_avail from
signed_word to word; add and refine comments; call find_nonbl_hblk,
next_hblk_fits_better and drop_hblk_in_chunks; simplify code in the
loop; rename lasthbp to last_hbp local variable; rename thishdr to
last_hdr local variable; remove thishbp local variable; add assertion
that hhdr->hb_sz>=size_needed.
* include/private/gc_priv.h (GC_allochblk): Move comment from
allchblk.c.
* include/private/gc_priv.h (GC_alloc_large) Move comment from
malloc.c.
* malloc.c (GC_alloc_large): Remove total_bytes local variable.
* malloc.c (GC_alloc_large, GC_alloc_large_and_clear,
GC_generic_malloc): Specify that result (or h) is unlikely to be NULL.
Diffstat (limited to 'alloc.c')
-rw-r--r-- | alloc.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -1395,7 +1395,7 @@ STATIC void GC_add_to_heap(struct hblk *p, size_t bytes) endp -= HBLKSIZE; } phdr = GC_install_header(p); - if (0 == phdr) { + if (EXPECT(NULL == phdr, FALSE)) { /* This is extremely unlikely. Can't add it. This will */ /* almost certainly result in a 0 return from the allocator, */ /* which is entirely appropriate. */ |