From dfadba718ffa54d03c6f09eff3ab13534579f07c Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sun, 12 Feb 2012 13:20:00 +0400 Subject: [PATCH] Minor code refactoring of GC_freehblk (change type of local variable) * allchblk.c (GC_freehblk): Change type of "size" local variable from singed_word to word; cast "hbp" to ptr_t instead of word (for getting "next" address). --- allchblk.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/allchblk.c b/allchblk.c index 92c60a88..98c26b89 100644 --- a/allchblk.c +++ b/allchblk.c @@ -341,7 +341,7 @@ STATIC void GC_remove_from_fl(hdr *hhdr, int n) phdr -> hb_next = hhdr -> hb_next; } FREE_ASSERT(GC_free_bytes[index] >= hhdr -> hb_sz); - INCR_FREE_BYTES(index, - (signed_word)(hhdr -> hb_sz)); + INCR_FREE_BYTES(index, -(signed_word)(hhdr -> hb_sz)); if (0 != hhdr -> hb_next) { hdr * nhdr; GC_ASSERT(!IS_FORWARDING_ADDR_OR_NIL(NHDR(hhdr))); @@ -839,7 +839,6 @@ GC_allochblk_nth(size_t sz, int kind, unsigned flags, int n, GC_fail_count = 0; GC_large_free_bytes -= size_needed; - GC_ASSERT(IS_MAPPED(hhdr)); return( hbp ); } @@ -855,17 +854,16 @@ GC_INNER void GC_freehblk(struct hblk *hbp) { struct hblk *next, *prev; hdr *hhdr, *prevhdr, *nexthdr; - signed_word size; + word size; GET_HDR(hbp, hhdr); - size = hhdr->hb_sz; - size = HBLKSIZE * OBJ_SZ_TO_BLOCKS(size); - if (size <= 0) + size = HBLKSIZE * OBJ_SZ_TO_BLOCKS(hhdr->hb_sz); + if ((signed_word)size <= 0) ABORT("Deallocating excessively large block. Too large an allocation?"); /* Probably possible if we try to allocate more than half the address */ /* space at once. If we don't catch it here, strange things happen */ /* later. */ - GC_remove_counts(hbp, (word)size); + GC_remove_counts(hbp, size); hhdr->hb_sz = size; # ifdef USE_MUNMAP hhdr -> hb_last_reclaimed = (unsigned short)GC_gc_no; @@ -881,7 +879,7 @@ GC_INNER void GC_freehblk(struct hblk *hbp) GC_ASSERT(IS_MAPPED(hhdr)); hhdr -> hb_flags |= FREE_BLK; - next = (struct hblk *)((word)hbp + size); + next = (struct hblk *)((ptr_t)hbp + size); GET_HDR(next, nexthdr); prev = GC_free_block_ending_at(hbp); /* Coalesce with successor, if possible */ -- 2.40.0