llvm.org GIT mirror llvm / 188b522
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 Evan Cheng 13 years ago
2 changed file(s) with 8 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2222 MallocAllocator() {}
2323 ~MallocAllocator() {}
2424
25 void Reset() {}
2526 void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); }
2627 void Deallocate(void *Ptr) { free(Ptr); }
2728 void PrintStats() const {}
3738 BumpPtrAllocator();
3839 ~BumpPtrAllocator();
3940
41 void Reset();
4042 void *Allocate(unsigned Size, unsigned Alignment);
4143 void Deallocate(void *Ptr) {}
4244 void PrintStats() const;
9191 ((MemRegion*)TheMemory)->Deallocate();
9292 }
9393
94 void BumpPtrAllocator::Reset() {
95 ((MemRegion*)TheMemory)->Deallocate();
96 TheMemory = malloc(4096);
97 ((MemRegion*)TheMemory)->Init(4096, 1, 0);
98 }
99
94100 void *BumpPtrAllocator::Allocate(unsigned Size, unsigned Align) {
95101 MemRegion *MRP = (MemRegion*)TheMemory;
96102 void *Ptr = MRP->Allocate(Size, Align, &MRP);