X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=rts%2FMBlock.c;h=85fe02da6e12a411b255e9194a8ce8e440f0a8b4;hp=9058205716e8c74be46de574ea865eaa695af538;hb=afef39736dcde6f4947a6f362f9e6b3586933db4;hpb=ab1e183aa7801f9260a9cbb6edbd553cf8249b25 diff --git a/rts/MBlock.c b/rts/MBlock.c index 9058205..85fe02d 100644 --- a/rts/MBlock.c +++ b/rts/MBlock.c @@ -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->basebase; 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->basebase; 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; @@ -408,7 +408,7 @@ findFreeBlocks(nat n) { if( (((unsigned long)it->base) & MBLOCK_MASK) == 0) { /* MBlock aligned */ ret = (void*)it->base; if(it->size==required_size) { - prev->next=0; + prev->next=it->next; stgFree(it); } else { it->base += required_size; @@ -442,7 +442,7 @@ static void commitBlocks(char* base, int size) { alloc_rec* it; it=allocs; - for( ; it!=0 && (it->base+it->size)next ) {} + for( ; it!=0 && (it->base+it->size)<=base; it=it->next ) {} for( ; it!=0 && size>0; it=it->next ) { int size_delta; void* temp;