[llvm-commits] CVS: poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Nov 3 15:15:02 PST 2003
Changes in directory poolalloc/runtime/PoolAllocator:
PoolAllocatorChained.cpp updated: 1.18 -> 1.19
---
Log message:
Fix bugs freeing memory
---
Diffs of the changes: (+8 -4)
Index: poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp
diff -u poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp:1.18 poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp:1.19
--- poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp:1.18 Mon Oct 27 14:38:57 2003
+++ poolalloc/runtime/PoolAllocator/PoolAllocatorChained.cpp Mon Nov 3 15:13:44 2003
@@ -455,9 +455,10 @@
int Idx = -1;
if (PS) { // Pool->Ptr1 could be null if Ptr2 isn't
PPS = (PoolSlab**)&Pool->Ptr1;
- PS->containsElement(Node, NodeSize);
- for (; Idx == -1 && PS; PPS = &PS->Next, PS = PS->Next)
+ for (; PS; PPS = &PS->Next, PS = PS->Next) {
Idx = PS->containsElement(Node, NodeSize);
+ if (Idx != -1) break;
+ }
}
// If the partially allocated slab list doesn't contain it, maybe the
@@ -465,12 +466,15 @@
if (PS == 0) {
PS = (PoolSlab*)Pool->Ptr2;
PPS = (PoolSlab**)&Pool->Ptr2;
+ assert(Idx == -1 && "Found node but don't have PS?");
- Idx = PS->containsElement(Node, NodeSize);
- for (; Idx == -1; PPS = &PS->Next, PS = PS->Next) {
+ while (1) {
assert(PS && "poolfree: node being free'd not found in allocation "
" pool specified!\n");
Idx = PS->containsElement(Node, NodeSize);
+ if (Idx != -1) break;
+ PPS = &PS->Next;
+ PS = PS->Next;
}
// Now that we found the node, we are about to free an element from it.
More information about the llvm-commits
mailing list