]> granicus.if.org Git - gc/commitdiff
Minor code refactoring of GC_freehblk (change type of local variable)
authorIvan Maidanski <ivmai@mail.ru>
Sun, 12 Feb 2012 09:20:00 +0000 (13:20 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 12 Feb 2012 09:20:00 +0000 (13:20 +0400)
* 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

index 92c60a885cbfcdaf68ec6085ceb42067a72b225a..98c26b89b26cda1afa5ffa5c2eb20be0d34cf142 100644 (file)
@@ -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 */