X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FMBlock.c;h=c886fd5ada5138f88f4baae52d37820bb84435e6;hb=93c274ab468687d45c3abf0b33314b5b554f133f;hp=15a4d2300e6b8e40652306f5b7c8b8248920add0;hpb=7ee5c6affd10895ddc3b1e09550069391faaa40a;p=ghc-hetmet.git diff --git a/rts/MBlock.c b/rts/MBlock.c index 15a4d23..c886fd5 100644 --- a/rts/MBlock.c +++ b/rts/MBlock.c @@ -337,20 +337,19 @@ allocNew(nat n) { if(rec->base==0) { stgFree((void*)rec); rec=0; - errorBelch( - "getMBlocks: VirtualAlloc MEM_RESERVE %d blocks failed with: %ld\n" - , n, GetLastError()); + 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; @@ -409,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; @@ -451,7 +450,7 @@ commitBlocks(char* base, int size) { if(size_delta>size) size_delta=size; temp = VirtualAlloc(base, size_delta, MEM_COMMIT, PAGE_READWRITE); if(temp==0) { - errorBelch("getMBlocks: VirtualAlloc MEM_COMMIT failed: %ld\n", GetLastError()); + sysErrorBelch("getMBlocks: VirtualAlloc MEM_COMMIT failed"); stg_exit(EXIT_FAILURE); } size-=size_delta; @@ -515,7 +514,7 @@ freeAllMBlocks(void) it=allocs; for(; it!=0; ) { if(!VirtualFree((void*)it->base, 0, MEM_RELEASE)) { - errorBelch("freeAllMBlocks: VirtualFree MEM_RELEASE failed with %ld", GetLastError()); + sysErrorBelch("freeAllMBlocks: VirtualFree MEM_RELEASE failed"); stg_exit(EXIT_FAILURE); } next = it->next;