CommonLibSSE (Parapets fork)
Loading...
Searching...
No Matches
ScrapHeap.h
Go to the documentation of this file.
1#pragma once
2
3#include "RE/I/IMemoryStore.h"
4
5namespace RE
6{
7 class ScrapHeap : public IMemoryStore
8 {
9 public:
10 inline static constexpr auto RTTI = RTTI_ScrapHeap;
11
12 struct Block
13 {
14 public:
15 // members
16 std::size_t sizeFlags; // 00
17 Block* prev; // 08
18 };
19 static_assert(sizeof(Block) == 0x10);
20
21 struct FreeBlock : public Block
22 {
23 public:
24 // members
27 };
28 static_assert(sizeof(FreeBlock) == 0x20);
29
30 struct FreeTreeNode : public Block
31 {
32 public:
33 // members
37 std::size_t parentAndBlack; // 28
38 };
39 static_assert(sizeof(FreeTreeNode) == 0x30);
40
42
43 // override (IMemoryStore)
44 std::size_t Size(void const* a_mem) const override { return *static_cast<const std::size_t*>(a_mem) & ~(std::size_t{ 3 } << 62); } // 01
45 void GetMemoryStats(MemoryStats*) override { return; } // 02
46 bool ContainsBlockImpl(const void* a_block) const override { return baseAddress <= a_block && a_block <= endAddress; } // 03
47 void* AllocateAlignImpl(std::size_t a_size, std::uint32_t a_alignment) override { return Allocate(a_size, a_alignment); } // 04
48 void DeallocateAlignImpl(void*& a_block) override { Deallocate(a_block), a_block = nullptr; } // 05
49
50 void* Allocate(std::size_t a_size, std::size_t a_alignment);
51 void Deallocate(void* a_mem);
52
53 // members
54 FreeBlock* smallBlocks[6]{ nullptr }; // 08
55 FreeTreeNode* freeList{ nullptr }; // 38
56 Block* lastBlock{ nullptr }; // 40
57 void* baseAddress{ nullptr }; // 48
58 void* endAddress{ nullptr }; // 50
59 void* commitEnd{ nullptr }; // 58
60 std::size_t reserveSize{ 1 << 26 }; // 60
61 std::size_t minCommit{ 1 << 17 }; // 68
62 std::size_t totalAllocated{ 0 }; // 70
63 std::uint32_t keepPagesRequest{ 0 }; // 78
64 std::uint32_t totalFreeBlocks{ 0 }; // 7C
65 std::uint32_t freeSmallBlocks{ 0 }; // 80
66 std::uint32_t totalAllocatedBlocks{ 0 }; // 84
67 std::uint32_t pmpBarrier{ 0 }; // 88
68 };
69 static_assert(sizeof(ScrapHeap) == 0x90);
70}
Definition: IMemoryStore.h:8
Definition: ScrapHeap.h:8
~ScrapHeap() override
Definition: ScrapHeap.h:41
void * Allocate(std::size_t a_size, std::size_t a_alignment)
std::size_t Size(void const *a_mem) const override
Definition: ScrapHeap.h:44
void Deallocate(void *a_mem)
bool ContainsBlockImpl(const void *a_block) const override
Definition: ScrapHeap.h:46
void * AllocateAlignImpl(std::size_t a_size, std::uint32_t a_alignment) override
Definition: ScrapHeap.h:47
std::uint32_t pmpBarrier
Definition: ScrapHeap.h:67
std::size_t reserveSize
Definition: ScrapHeap.h:60
std::uint32_t freeSmallBlocks
Definition: ScrapHeap.h:65
Block * lastBlock
Definition: ScrapHeap.h:56
std::uint32_t keepPagesRequest
Definition: ScrapHeap.h:63
static constexpr auto RTTI
Definition: ScrapHeap.h:10
std::size_t totalAllocated
Definition: ScrapHeap.h:62
FreeTreeNode * freeList
Definition: ScrapHeap.h:55
std::uint32_t totalAllocatedBlocks
Definition: ScrapHeap.h:66
std::uint32_t totalFreeBlocks
Definition: ScrapHeap.h:64
void * baseAddress
Definition: ScrapHeap.h:57
std::size_t minCommit
Definition: ScrapHeap.h:61
void * commitEnd
Definition: ScrapHeap.h:59
void GetMemoryStats(MemoryStats *) override
Definition: ScrapHeap.h:45
void * endAddress
Definition: ScrapHeap.h:58
FreeBlock * smallBlocks[6]
Definition: ScrapHeap.h:54
void DeallocateAlignImpl(void *&a_block) override
Definition: ScrapHeap.h:48
Definition: AbsorbEffect.h:6
constexpr REL::ID RTTI_ScrapHeap
Definition: Offsets_RTTI.h:5794
constexpr auto MEM_RELEASE
Definition: WinAPI.h:10
bool VirtualFree(void *a_address, std::size_t a_size, std::uint32_t a_freeType) noexcept
Definition: IMemoryStoreBase.h:6
Definition: ScrapHeap.h:13
Block * prev
Definition: ScrapHeap.h:17
std::size_t sizeFlags
Definition: ScrapHeap.h:16
Definition: ScrapHeap.h:22
FreeBlock * right
Definition: ScrapHeap.h:26
FreeBlock * left
Definition: ScrapHeap.h:25
Definition: ScrapHeap.h:31
FreeTreeNode * leftNode
Definition: ScrapHeap.h:35
std::size_t parentAndBlack
Definition: ScrapHeap.h:37
FreeTreeNode * rightNode
Definition: ScrapHeap.h:36
FreeTreeNode ** root
Definition: ScrapHeap.h:34