diff options
author | Torok Edwin <edwintorok@gmail.com> | 2010-03-30 11:17:48 +0000 |
---|---|---|
committer | Torok Edwin <edwintorok@gmail.com> | 2010-03-30 11:17:48 +0000 |
commit | 8061bb141e735ed41543d9ebd8f8e47bde70886a (patch) | |
tree | 01114ddf11ccb8dc20f5bae5bf1688b2ca231da9 /llvm/lib/Support/Allocator.cpp | |
parent | a2d1dc42e1ad19ccf028b837ae788fd832422871 (diff) | |
download | llvm-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.cpp | 15 |
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) { |