1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Added Reset() to free all allocated memory regions and reset state to be the same as right after ctor.

llvm-svn: 41728
This commit is contained in:
Evan Cheng 2007-09-05 21:41:34 +00:00
parent 804e104123
commit 5977c55f5d
2 changed files with 8 additions and 0 deletions

View File

@ -23,6 +23,7 @@ public:
MallocAllocator() {}
~MallocAllocator() {}
void Reset() {}
void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); }
void Deallocate(void *Ptr) { free(Ptr); }
void PrintStats() const {}
@ -38,6 +39,7 @@ public:
BumpPtrAllocator();
~BumpPtrAllocator();
void Reset();
void *Allocate(unsigned Size, unsigned Alignment);
void Deallocate(void *Ptr) {}
void PrintStats() const;

View File

@ -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);