Fix Windows MBlock alloctor bookkeeping bug
authorEsa Ilari Vuokko <ei@vuokko.info>
Wed, 30 Aug 2006 18:55:40 +0000 (18:55 +0000)
committerEsa Ilari Vuokko <ei@vuokko.info>
Wed, 30 Aug 2006 18:55:40 +0000 (18:55 +0000)
rts/MBlock.c

index 9058205..edde679 100644 (file)
@@ -340,16 +340,16 @@ allocNew(nat n) {
         sysErrorBelch(
             "getMBlocks: VirtualAlloc MEM_RESERVE %d blocks failed", n);
     } else {
-        if(allocs==0) {
-            allocs=rec;
-            rec->next=0;
-        } else {
-            alloc_rec* it;
-            it=allocs;
-            for(; it->next!=0 && it->next->base<rec->base; it=it->next) ;
-            rec->next=it->next;
-            it->next=rec;
-        }
+               alloc_rec temp;
+               temp.base=0; temp.size=0; temp.next=allocs;
+
+        alloc_rec* it;
+        it=&temp;
+        for(; it->next!=0 && it->next->base<rec->base; it=it->next) ;
+        rec->next=it->next;
+        it->next=rec;
+
+               allocs=temp.next;
         debugTrace(DEBUG_gc, "allocated %d megablock(s) at 0x%x",n,(nat)rec->base);
     }
     return rec;