Add BumpPtrAllocator::getTotalMemory() to allow clients to query how much memory...
[oota-llvm.git] / lib / Support / Allocator.cpp
index 5e27df6628ebbb2524d70eb4f02b3d366fede742..215b0f249d96f82cda56763998be5326fae3569e 100644 (file)
@@ -136,6 +136,14 @@ unsigned BumpPtrAllocator::GetNumSlabs() const {
   return NumSlabs;
 }
 
+size_t BumpPtrAllocator::getTotalMemory() const {
+  size_t TotalMemory = 0;
+  for (MemSlab *Slab = CurSlab; Slab != 0; Slab = Slab->NextPtr) {
+    TotalMemory += Slab->Size;
+  }
+  return TotalMemory;
+}
+  
 void BumpPtrAllocator::PrintStats() const {
   unsigned NumSlabs = 0;
   size_t TotalMemory = 0;