[llvm-commits] CVS: poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp
John Criswell
criswell at cs.uiuc.edu
Fri Nov 14 11:54:01 PST 2003
Changes in directory poolalloc/runtime/FreeListAllocator:
PoolAllocator.cpp updated: 1.23 -> 1.24
---
Log message:
Simplified code that scans the free array list looking for a slab.
Corrected the free array scanning code to update fields when an array slab
is allocated.
---
Diffs of the changes: (+24 -16)
Index: poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp
diff -u poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.23 poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.24
--- poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp:1.23 Fri Nov 14 11:38:01 2003
+++ poolalloc/runtime/FreeListAllocator/PoolAllocator.cpp Fri Nov 14 11:53:31 2003
@@ -322,7 +322,7 @@
// Scan the list of array slabs to see if there is one that fits.
//
struct SlabHeader * Slabp = Pool->ArraySlabs;
- struct SlabHeader * Prevp = NULL;
+ struct SlabHeader ** Prevp = &(Pool->ArraySlabs);
//
// Check to see if we have an array slab that has extra space that we
@@ -348,30 +348,38 @@
// Scan through all the free array slabs to see if they are large
// enough.
//
- for (; Slabp != NULL; Prevp = Slabp, Slabp=Slabp->Next)
+ for (; Slabp != NULL; Slabp=Slabp->Next)
{
//
// Check to see if this slab has enough room.
//
if (Slabp->NodesPerSlab >= ArraySize)
{
- if (Prevp == NULL)
- {
- //
- // This is the first item. Change the head of the list.
- //
- Pool->ArraySlabs = Slabp->Next;
- }
- else
- {
- //
- // This is some other item. Modify the preceding item.
- //
- Prevp->Next = Slabp->Next;
- }
+ //
+ // Make the previous node point to the next node.
+ //
+ (*Prevp)->Next = Slabp->Next;
+
+ //
+ // Increase the reference count of the slab.
+ //
++(Slabp->LiveNodes);
+
+ //
+ // Adjust the slab's index of data blocks.
+ //
+ Slabp->NextFreeData = ArraySize;
+
+ //
+ // Return the slab's data.
+ //
return (Slabp->Data);
}
+
+ //
+ // Move on to the next node.
+ //
+ Prevp = &(Slabp->Next);
}
//
More information about the llvm-commits
mailing list