aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-09-05 21:41:34 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-09-05 21:41:34 +0000
commit72ac148499ae3399ba6dea44e959d0efc0f08573 (patch)
tree6b97248e10a979a06994e1ff05da6d5ee0abeaf0 /lib
parent2e9830dc56a6c41b350106b1dbc6745ad4f3eef7 (diff)
downloadexternal_llvm-72ac148499ae3399ba6dea44e959d0efc0f08573.zip
external_llvm-72ac148499ae3399ba6dea44e959d0efc0f08573.tar.gz
external_llvm-72ac148499ae3399ba6dea44e959d0efc0f08573.tar.bz2
Added Reset() to free all allocated memory regions and reset state to be the same as right after ctor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41728 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/Allocator.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp
index 234fd41..e68c3e2 100644
--- a/lib/Support/Allocator.cpp
+++ b/lib/Support/Allocator.cpp
@@ -92,6 +92,12 @@ BumpPtrAllocator::~BumpPtrAllocator() {
((MemRegion*)TheMemory)->Deallocate();
}
+void BumpPtrAllocator::Reset() {
+ ((MemRegion*)TheMemory)->Deallocate();
+ TheMemory = malloc(4096);
+ ((MemRegion*)TheMemory)->Init(4096, 1, 0);
+}
+
void *BumpPtrAllocator::Allocate(unsigned Size, unsigned Align) {
MemRegion *MRP = (MemRegion*)TheMemory;
void *Ptr = MRP->Allocate(Size, Align, &MRP);