[llvm-commits] CVS: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Feb 24 15:04:01 PST 2004
Changes in directory poolalloc/runtime/FL2Allocator:
FreeListAllocator.cpp updated: 1.3 -> 1.4
---
Log message:
Add these two lines:
+ if (LAH->Next)
+ LAH->Next->Prev = &LAH->Next;
Which fix a really nasty memory corruption problem, and makes pcompress2 work! :)
---
Diffs of the changes: (+13 -0)
Index: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp
diff -u poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.3 poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.4
--- poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.3 Thu Feb 19 23:25:48 2004
+++ poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Tue Feb 24 15:02:56 2004
@@ -74,6 +74,8 @@
Pool->Slabs = 0;
Pool->FreeNodeList = 0;
Pool->LargeArrays = 0;
+
+ //printf("init pool 0x%X\n", Pool);
}
// pooldestroy - Release all memory allocated for a pool
@@ -81,6 +83,8 @@
void pooldestroy(PoolTy *Pool) {
assert(Pool && "Null pool pointer passed in to pooldestroy!\n");
+ //printf("destroy pool 0x%X\n", Pool);
+
// Free all allocated slabs.
PoolSlab *PS = Pool->Slabs;
while (PS) {
@@ -117,10 +121,12 @@
NextNodes->NormalHeader.Next = FirstNode->NormalHeader.Next;
Pool->FreeNodeList = NextNodes;
FirstNode->NormalHeader.ObjectSize = NumBytes;
+ //printf("alloc 0x%X -> 0x%X\n", Pool, &FirstNode->NormalHeader+1);
return &FirstNode->NormalHeader+1;
} else if (FirstNodeSize > NumBytes) {
Pool->FreeNodeList = FirstNode->NormalHeader.Next; // Unlink
FirstNode->NormalHeader.ObjectSize = FirstNodeSize;
+ //printf("alloc 0x%X -> 0x%X\n", Pool, &FirstNode->NormalHeader+1);
return &FirstNode->NormalHeader+1;
}
}
@@ -148,10 +154,12 @@
NextNodes->NormalHeader.Next = FNN->NormalHeader.Next;
*FN = NextNodes;
FNN->NormalHeader.ObjectSize = NumBytes;
+ //printf("alloc 0x%X -> 0x%X\n", Pool, &FNN->NormalHeader+1);
return &FNN->NormalHeader+1;
} else {
*FN = FNN->NormalHeader.Next; // Unlink
FNN->NormalHeader.ObjectSize = FNN->Size;
+ //printf("alloc 0x%X -> 0x%X\n", Pool, &FNN->NormalHeader+1);
return &FNN->NormalHeader+1;
}
}
@@ -167,9 +175,12 @@
LargeArrayHeader *LAH = (LargeArrayHeader*)malloc(sizeof(LargeArrayHeader) +
NumBytes);
LAH->Next = Pool->LargeArrays;
+ if (LAH->Next)
+ LAH->Next->Prev = &LAH->Next;
Pool->LargeArrays = LAH;
LAH->Prev = &Pool->LargeArrays;
LAH->Marker = ~0U;
+ //printf("alloc large 0x%X -> 0x%X\n", Pool, LAH+1);
return LAH+1;
}
@@ -177,6 +188,8 @@
void poolfree(PoolTy *Pool, void *Node) {
assert(Pool && "Null pool pointer passed in to poolfree!\n");
if (Node == 0) return;
+
+ //printf("free 0x%X <- 0x%X\n", Pool, Node);
// Check to see how many elements were allocated to this node...
FreedNodeHeader *FNH = (FreedNodeHeader*)((char*)Node-sizeof(NodeHeader));
More information about the llvm-commits
mailing list