Eliminate 'scope of variable can be reduced' cppcheck warning in allchblk
authorIvan Maidanski <ivmai@mail.ru>
Wed, 5 Oct 2016 20:58:00 +0000 (23:58 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 5 Oct 2016 20:58:00 +0000 (23:58 +0300)
* allchblk.c [USE_MUNMAP] (GC_merge_unmapped): Move local variable
declarations to the inner scope where the variables are actually used.

allchblk.c

index 1481264..df9b6b0 100644 (file)
@@ -419,14 +419,16 @@ GC_INNER void GC_unmap_old(void)
 /* fully mapped or fully unmapped.                                      */
 GC_INNER void GC_merge_unmapped(void)
 {
-    struct hblk * h, *next;
-    hdr * hhdr, *nexthdr;
-    word size, nextsize;
     int i;
 
     for (i = 0; i <= N_HBLK_FLS; ++i) {
-      h = GC_hblkfreelist[i];
+      struct hblk *h = GC_hblkfreelist[i];
+
       while (h != 0) {
+        struct hblk *next;
+        hdr *hhdr, *nexthdr;
+        word size, nextsize;
+
         GET_HDR(h, hhdr);
         size = hhdr->hb_sz;
         next = (struct hblk *)((word)h + size);