mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-20 14:29:27 +00:00
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
This commit is contained in:
parent
df344febe2
commit
188b5224fd
@ -23,6 +23,7 @@ public:
|
|||||||
MallocAllocator() {}
|
MallocAllocator() {}
|
||||||
~MallocAllocator() {}
|
~MallocAllocator() {}
|
||||||
|
|
||||||
|
void Reset() {}
|
||||||
void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); }
|
void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); }
|
||||||
void Deallocate(void *Ptr) { free(Ptr); }
|
void Deallocate(void *Ptr) { free(Ptr); }
|
||||||
void PrintStats() const {}
|
void PrintStats() const {}
|
||||||
@ -38,6 +39,7 @@ public:
|
|||||||
BumpPtrAllocator();
|
BumpPtrAllocator();
|
||||||
~BumpPtrAllocator();
|
~BumpPtrAllocator();
|
||||||
|
|
||||||
|
void Reset();
|
||||||
void *Allocate(unsigned Size, unsigned Alignment);
|
void *Allocate(unsigned Size, unsigned Alignment);
|
||||||
void Deallocate(void *Ptr) {}
|
void Deallocate(void *Ptr) {}
|
||||||
void PrintStats() const;
|
void PrintStats() const;
|
||||||
|
@ -92,6 +92,12 @@ BumpPtrAllocator::~BumpPtrAllocator() {
|
|||||||
((MemRegion*)TheMemory)->Deallocate();
|
((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) {
|
void *BumpPtrAllocator::Allocate(unsigned Size, unsigned Align) {
|
||||||
MemRegion *MRP = (MemRegion*)TheMemory;
|
MemRegion *MRP = (MemRegion*)TheMemory;
|
||||||
void *Ptr = MRP->Allocate(Size, Align, &MRP);
|
void *Ptr = MRP->Allocate(Size, Align, &MRP);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user