AuroraRuntime/Source/Memory/AuHeapProxy.hpp

42 lines
1.6 KiB
C++

/***
Copyright (C) 2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuHeapProxy.hpp
Date: 2024-1-16
Author: Reece
***/
namespace Aurora::Memory
{
struct ProxyHeap : BaseHeap
{
std::shared_ptr<Heap> pHeap;
LeakFinderAlloc_f pAlloc;
LeakFinderFree_f pFree;
AuUInt uBytesAllocated {}; // current
AuUInt uBytesPeak {}; // max
AuUInt uBytesFree {}; // free count
AuUInt uBytesLifetime {}; // alloc count
ProxyHeap(std::shared_ptr<Heap> pHeap,
LeakFinderAlloc_f pAlloc = {},
LeakFinderFree_f pFree = {});
void UpdateStats() override;
AuSPtr<Heap> GetSelfReference() override;
Heap *GetSelfReferenceRaw() override;
AuSPtr<Heap> AllocateDivision(AuUInt32 heap, AuUInt32 alignment) override;
void *_ZAlloc(Types::size_t length) override;
void *_ZAlloc(Types::size_t length, Types::size_t align) override;
Types::size_t GetChunkSize(const void *head) override;
void *_FAlloc(Types::size_t length) override;
void *_FAlloc(Types::size_t length, Types::size_t align) override;
void *_ZRealloc(void *buffer, Types::size_t length, Types::size_t align) override;
void *_ZRealloc(void *buffer, Types::size_t length) override;
void *_FRealloc(void *buffer, Types::size_t length, Types::size_t align) override;
void *_FRealloc(void *buffer, Types::size_t length) override;
void _Free(void *buffer) override;
void WalkHeap(bool(*fCallback)(void *, void *), void *pSecondArg) override;
};
}