2022-01-16 06:59:00 +00:00
|
|
|
#pragma once
|
|
|
|
#include <list>
|
|
|
|
|
2022-01-17 02:30:47 +00:00
|
|
|
#include "Runtime/GCNTypes.hpp"
|
|
|
|
|
2022-01-16 06:59:00 +00:00
|
|
|
|
|
|
|
namespace metaforce {
|
2022-01-17 02:30:47 +00:00
|
|
|
struct SMediumAllocPuddle {
|
|
|
|
bool x0_hasBuffer; // was an auto_ptr
|
|
|
|
void* x4_mainData; // ""
|
|
|
|
void* x8_bookKeeping;
|
|
|
|
void* xc_cachedBookKeepingAddr = nullptr;
|
|
|
|
s32 x10_ = -1;
|
|
|
|
u32 x14_numBlocks;
|
|
|
|
u32 x18_numAllocs = 0;
|
|
|
|
u32 x1c_numEntries;
|
|
|
|
bool x20_24_canErase : 1;
|
|
|
|
|
|
|
|
void* FindFreeEntry(u32 blockCount);
|
|
|
|
public:
|
|
|
|
SMediumAllocPuddle(u32 numBlocks, void* ptr, bool canErase);
|
|
|
|
void* FindFree(u32 blockCount);
|
|
|
|
|
|
|
|
void Free(void* ptr);
|
|
|
|
};
|
|
|
|
|
2022-01-16 06:59:00 +00:00
|
|
|
class CMediumAllocPool {
|
|
|
|
std::list<SMediumAllocPuddle> x0_puddles;
|
2022-01-17 02:30:47 +00:00
|
|
|
std::list<SMediumAllocPuddle>::iterator x18_lastPuddle;
|
2022-01-16 06:59:00 +00:00
|
|
|
public:
|
2022-01-17 02:30:47 +00:00
|
|
|
CMediumAllocPool();
|
2022-01-16 06:59:00 +00:00
|
|
|
|
2022-01-17 02:30:47 +00:00
|
|
|
void* Alloc(u32 len);
|
|
|
|
bool Free(void* ptr);
|
|
|
|
void AddPuddle(u32 numBlocks, void* ptr, bool v);
|
2022-01-16 06:59:00 +00:00
|
|
|
u32 GetTotalEntries() const;
|
|
|
|
u32 GetNumBlocksAvailable() const;
|
|
|
|
u32 GetNumAllocs() const;
|
2022-01-17 02:30:47 +00:00
|
|
|
bool HasPuddles() const { return !x0_puddles.empty(); }
|
2022-01-16 06:59:00 +00:00
|
|
|
};
|
|
|
|
}
|