2016-04-13 06:07:23 +00:00
|
|
|
#ifndef __URDE_CGAMEALLOCATOR_HPP__
|
|
|
|
#define __URDE_CGAMEALLOCATOR_HPP__
|
2015-08-17 05:26:58 +00:00
|
|
|
|
|
|
|
#include "IAllocator.hpp"
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-17 22:05:00 +00:00
|
|
|
{
|
2015-08-23 18:53:43 +00:00
|
|
|
class CCallStack;
|
2015-08-17 22:05:00 +00:00
|
|
|
|
2015-08-17 05:26:58 +00:00
|
|
|
class CGameAllocator : public IAllocator
|
|
|
|
{
|
|
|
|
public:
|
2015-08-23 18:53:43 +00:00
|
|
|
struct SGameMemInfo
|
|
|
|
{
|
|
|
|
};
|
|
|
|
private:
|
2015-08-23 23:58:07 +00:00
|
|
|
SGameMemInfo* x10_rootInfo = nullptr;
|
|
|
|
TOutOfMemoryCallback x58_oomCb = nullptr;
|
|
|
|
void* x5c_oomCtx = nullptr;
|
2015-08-23 18:53:43 +00:00
|
|
|
u32 xbc_fakeStaticOff = 0;
|
|
|
|
public:
|
|
|
|
SGameMemInfo* FindFreeBlock(u32);
|
|
|
|
SGameMemInfo* FindFreeBlockFromTopOfHeap(u32);
|
|
|
|
u32 FixupAllocPtrs(SGameMemInfo*, u32, u32, EHint, const CCallStack&);
|
|
|
|
void UpdateAllocDebugStats(u32, u32, u32);
|
|
|
|
bool FreeNormalAllocation(void*);
|
|
|
|
u32 GetFreeBinEntryForSize(u32);
|
|
|
|
void AddFreeEntryToFreeList(SGameMemInfo*);
|
|
|
|
void RemoveFreeEntryFromFreeList(SGameMemInfo*);
|
|
|
|
void DumpAllocations() const;
|
|
|
|
u32 GetLargestFreeChunk() const;
|
2015-08-23 23:58:07 +00:00
|
|
|
SGameMemInfo* GetMemInfoFromBlockPtr(void* ptr);
|
2015-08-23 18:53:43 +00:00
|
|
|
|
2015-08-28 00:11:31 +00:00
|
|
|
bool Initialize();
|
2015-08-17 05:26:58 +00:00
|
|
|
void Shutdown();
|
2015-08-23 23:58:07 +00:00
|
|
|
void* Alloc(size_t, EHint, EScope, EType, const CCallStack&);
|
2015-08-23 18:53:43 +00:00
|
|
|
void Free(void*);
|
|
|
|
void ReleaseAll();
|
2015-08-23 23:58:07 +00:00
|
|
|
void* AllocSecondary(size_t, EHint, EScope, EType, const CCallStack&);
|
2015-08-23 18:53:43 +00:00
|
|
|
void FreeSecondary(void*);
|
|
|
|
void ReleaseAllSecondary();
|
|
|
|
void SetOutOfMemoryCallback(const TOutOfMemoryCallback, void*);
|
|
|
|
int EnumAllocations(const TAllocationVisitCallback, void*, bool) const;
|
|
|
|
SAllocInfo GetAllocInfo(void*) const;
|
|
|
|
void OffsetFakeStatics(int);
|
|
|
|
SMetrics GetMetrics() const;
|
2015-08-17 05:26:58 +00:00
|
|
|
};
|
|
|
|
|
2015-08-17 22:05:00 +00:00
|
|
|
}
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
#endif // __URDE_CGAMEALLOCATOR_HPP__
|