prime/include/Kyoto/Alloc/CMediumAllocPool.hpp

54 lines
1.4 KiB
C++
Raw Normal View History

#ifndef _CMEDIUMALLOCPOOL
#define _CMEDIUMALLOCPOOL
2022-09-20 04:35:24 +00:00
2023-10-03 05:36:22 +00:00
#include <rstl/auto_ptr.hpp>
2022-09-20 04:35:24 +00:00
#include <rstl/list.hpp>
2023-10-03 05:36:22 +00:00
struct SMediumAllocPuddle {
SMediumAllocPuddle(uint numBlocks, void* ptr, const bool unk);
~SMediumAllocPuddle();
void* FindFree(uint blockCount);
void* FindFreeEntry(uint blockCount);
bool Free(const void* ptr);
uint GetUnkx10() const { return x10_; }
uint GetNumBlocks() const { return x14_numBlocks; }
uint GetNumAllocs() const { return x18_numAllocs; }
uint GetNumEntries() const { return x1c_numEntries; }
bool GetUnk2() const { return x20_unk2; }
static uint GetBlockOffset(const void* ptrA, const void* ptrB);
static void InitBookKeeping(void* bookKeepingPtr, uint blockCount);
private:
rstl::auto_ptr< void > x0_mainData;
uchar* x8_bookKeeping;
uchar* xc_cachedBookKeepingAddr;
uint x10_;
uint x14_numBlocks;
uint x18_numAllocs;
uint x1c_numEntries;
bool x20_unk2 : 1;
};
2022-09-20 04:35:24 +00:00
class CMediumAllocPool {
public:
rstl::list< SMediumAllocPuddle > x0_list;
2023-10-03 05:36:22 +00:00
rstl::list< SMediumAllocPuddle >::node* x18_lastNodePrev;
CMediumAllocPool();
void* Alloc(uint size);
bool HasPuddles() const;
2023-10-03 05:36:22 +00:00
void AddPuddle(uint, void*, bool);
void ClearPuddles();
2022-09-20 04:35:24 +00:00
int Free(const void* ptr);
2022-09-20 04:35:24 +00:00
uint GetTotalEntries();
uint GetNumBlocksAvailable();
uint GetNumAllocs();
static CMediumAllocPool* gMediumAllocPtr;
2022-09-20 04:35:24 +00:00
};
#endif // _CMEDIUMALLOCPOOL