[llvm-commits] CVS: poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp

Dinakar Dhurjati dhurjati at cs.uiuc.edu
Sat Nov 8 18:38:01 PST 2003


Changes in directory poolalloc/runtime/PoolAllocator:

PoolAllocatorBitMask.cpp updated: 1.28 -> 1.29

---
Log message:

Added poolcheck based on SearchForContainingSlab,


---
Diffs of the changes:  (+33 -0)

Index: poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp
diff -u poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp:1.28 poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp:1.29
--- poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp:1.28	Sat Nov  8 16:44:59 2003
+++ poolalloc/runtime/PoolAllocator/PoolAllocatorBitMask.cpp	Sat Nov  8 18:37:16 2003
@@ -630,6 +630,39 @@
   return PS;
 }
 
+// same as above, but this is the actual run time check called from the
+// code to check if the node belongs to the pool or not, so will be 
+// like crazy, (use a hash table ?)
+// FIXME cannot call this for pointers in the middle of the node yet,
+// asserts out if we do
+void poolcheck(PoolTy *Pool, void *Node) {
+   PoolSlab *PS = (PoolSlab*)Pool->Ptr1;
+  unsigned NodeSize = Pool->NodeSize;
+
+  // Search the partially allocated slab list for the slab that contains this
+  // node.
+  int Idx = -1;
+  if (PS) {               // Pool->Ptr1 could be null if Ptr2 isn't
+    for (; PS; PS = PS->Next) {
+      Idx = PS->containsElement(Node, NodeSize);
+      if (Idx != -1) break;
+    }
+  }
+
+  // If the partially allocated slab list doesn't contain it, maybe the
+  // completely allocated list does.
+  if (PS == 0) {
+    PS = (PoolSlab*)Pool->Ptr2;
+    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;
+      PS = PS->Next;
+    }
+  }
+}
+
 void poolfree(PoolTy *Pool, void *Node) {
   assert(Pool && "Null pool pointer passed in to poolfree!\n");
 





More information about the llvm-commits mailing list