2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2017-09-12 15:27:48 +00:00
|
|
|
|
2019-09-22 21:52:05 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
2017-09-12 15:27:48 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
|
|
|
class CGameAllocator {
|
|
|
|
struct SAllocationDescription {
|
|
|
|
std::unique_ptr<u8[]> memptr;
|
|
|
|
size_t allocSize = 0;
|
|
|
|
ptrdiff_t freeOffset = 0;
|
|
|
|
};
|
2017-09-12 15:27:48 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct SChunkDescription {
|
|
|
|
u32 magic = 0xE8E8E8E8;
|
|
|
|
SAllocationDescription* parent;
|
|
|
|
size_t len = 0;
|
|
|
|
u32 sentinal = 0xEFEFEFEF;
|
|
|
|
};
|
2017-09-12 15:27:48 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static std::vector<SAllocationDescription> m_allocations;
|
2017-09-12 15:27:48 +00:00
|
|
|
|
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
static u8* Alloc(size_t len);
|
|
|
|
static void Free(u8* ptr);
|
2017-09-12 15:27:48 +00:00
|
|
|
};
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|