summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Allocator.cpp
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
commit3dba41bf37f76392743f9defa3e70309e350ba79 (patch)
treebe786e7871c320c8e3844928e484494fe712fbd0 /llvm/lib/Support/Allocator.cpp
parent19ce37a1cdf8df96afc9f0f6c4f506265ba9fded (diff)
downloadbcm5719-llvm-3dba41bf37f76392743f9defa3e70309e350ba79.tar.gz
bcm5719-llvm-3dba41bf37f76392743f9defa3e70309e350ba79.zip
Added Reset() to free all allocated memory regions and reset state to be the same as right after ctor.
llvm-svn: 41728
Diffstat (limited to 'llvm/lib/Support/Allocator.cpp')
-rw-r--r--llvm/lib/Support/Allocator.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Support/Allocator.cpp b/llvm/lib/Support/Allocator.cpp
index 234fd41b738..e68c3e26c7d 100644
--- a/llvm/lib/Support/Allocator.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud