aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Allocator.cpp
diff options
context:
space:
mode:
authorTorok Edwin <edwintorok@gmail.com>2010-03-30 11:17:48 +0000
committerTorok Edwin <edwintorok@gmail.com>2010-03-30 11:17:48 +0000
commit8061bb141e735ed41543d9ebd8f8e47bde70886a (patch)
tree01114ddf11ccb8dc20f5bae5bf1688b2ca231da9 /llvm/lib/Support/Allocator.cpp
parenta2d1dc42e1ad19ccf028b837ae788fd832422871 (diff)
downloadllvm-8061bb141e735ed41543d9ebd8f8e47bde70886a.zip
llvm-8061bb141e735ed41543d9ebd8f8e47bde70886a.tar.gz
llvm-8061bb141e735ed41543d9ebd8f8e47bde70886a.tar.bz2
Reapply r99881 with some fixes: only call destructor in releaseMemory!
llvm-svn: 99883
Diffstat (limited to 'llvm/lib/Support/Allocator.cpp')
-rw-r--r--llvm/lib/Support/Allocator.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Support/Allocator.cpp b/llvm/lib/Support/Allocator.cpp
index 31b45c8..7433247 100644
--- a/llvm/lib/Support/Allocator.cpp
+++ b/llvm/lib/Support/Allocator.cpp
@@ -78,6 +78,21 @@ void BumpPtrAllocator::Reset() {
End = ((char*)CurSlab) + CurSlab->Size;
}
+void BumpPtrAllocator::Reset(size_t Size, size_t Alignment, DTorFunction DTor) {
+ if (Alignment == 0) Alignment = 1;
+ MemSlab *Slab = CurSlab;
+ while (Slab) {
+ char *End = Slab == CurSlab ? CurPtr : (char*)Slab + Slab->Size;
+ for (char *Ptr = (char*)Slab+1; Ptr < End; Ptr += Size) {
+ Ptr = AlignPtr(Ptr, Alignment);
+ if (Ptr + Size <= End)
+ DTor(Ptr);
+ }
+ Slab = Slab->NextPtr;
+ }
+ Reset();
+}
+
/// Allocate - Allocate space at the specified alignment.
///
void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) {