diff options
-rw-r--r-- | include/llvm/Support/Allocator.h | 4 | ||||
-rw-r--r-- | lib/Support/Allocator.cpp | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index b0ed33d..496496b 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -128,11 +128,11 @@ class BumpPtrAllocator { /// one. void DeallocateSlabs(MemSlab *Slab); - static MallocSlabAllocator DefaultSlabAllocator; + static MallocSlabAllocator &GetDefaultSlabAllocator(); public: BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, - SlabAllocator &allocator = DefaultSlabAllocator); + SlabAllocator &allocator = GetDefaultSlabAllocator()); ~BumpPtrAllocator(); /// Reset - Deallocate all but the current slab and reset the current pointer diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp index 31b45c8..19d69f6 100644 --- a/lib/Support/Allocator.cpp +++ b/lib/Support/Allocator.cpp @@ -142,8 +142,10 @@ void BumpPtrAllocator::PrintStats() const { << " (includes alignment, etc)\n"; } -MallocSlabAllocator BumpPtrAllocator::DefaultSlabAllocator = - MallocSlabAllocator(); +MallocSlabAllocator &BumpPtrAllocator::GetDefaultSlabAllocator() { + static MallocSlabAllocator DefaultSlabAllocator; + return DefaultSlabAllocator; +} SlabAllocator::~SlabAllocator() { } |