CommonLibSSE NG
BSSmallBlockAllocator.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSAtomic.h"
4 #include "RE/I/IMemoryStore.h"
5 
6 namespace RE
7 {
8  namespace BSSmallBlockAllocatorUtil
9  {
10  struct FreeBlock
11  {
12  public:
13  // members
14  FreeBlock* next; // 0
15  };
16  static_assert(sizeof(FreeBlock) == 0x8);
17 
18  struct BlockPage
19  {
20  public:
21  // members
22  BlockPage* left; // 00
23  BlockPage* right; // 08
24  FreeBlock* blocks; // 10
25  std::uint16_t totalElem; // 18
26  std::uint16_t freeElem; // 1A
27  std::uint32_t pad1C; // 1C
28  };
29  static_assert(sizeof(BlockPage) == 0x20);
30 
31  struct Pool
32  {
33  public:
34  // members
37  std::uint32_t totalFreeBlocks; // 10
38  std::uint32_t totalAllocatedBlocks; // 14
39  std::uint32_t totalBytes; // 18
40  std::uint32_t elementSize; // 1C
42  };
43  static_assert(sizeof(Pool) == 0x48);
44  }
45 
47  {
48  public:
49  // members
53  std::uint16_t totalElem; // 18
54  std::uint16_t freeElem; // 1A
55  std::uint16_t elemSize; // 1C
56  std::uint16_t check; // 1E
57  };
58  static_assert(sizeof(BlockPageInternal) == 0x20);
59 
61  {
62  public:
63  inline static constexpr auto RTTI = RTTI_BSSmallBlockAllocator;
64 
66  {
67  public:
68  };
69  static_assert(sizeof(Pool) == 0x48);
70 
72  {
73  public:
74  // members
75  char mem[sizeof(BlockPageInternal[255]) * 256]; // 000000
76  BlockPageInternal blockPages[255]; // 1FE000
77  MegaBlockPage* left; // 1FFFE0
78  MegaBlockPage* right; // 1FFFE8
80  std::uint16_t numFreeBlockPages; // 1FFFF8
81  std::uint16_t nextBlockPageAlloc; // 1FFFFA
82  bool decommitted; // 1FFFFC
83  std::uint8_t pad1FFFFD; // 1FFFFD
84  std::uint16_t pad1FFFFE; // 1FFFFE
85  };
86  static_assert(sizeof(MegaBlockPage) == 0x200000);
87 
88  ~BSSmallBlockAllocator() override; // 00
89 
90  // override (IMemoryStore)
91  std::size_t Size(const void* a_block) const override; // 01
92  void GetMemoryStats(MemoryStats* a_stats) override; // 02
93  bool ContainsBlockImpl(const void* a_block) const override; // 03
94  void* AllocateAlignImpl(std::size_t a_size, std::uint32_t a_alignment) override; // 04
95  void DeallocateAlignImpl(void*& a_freeBlock) override; // 05
96  void* TryAllocateImpl(std::size_t a_size, std::uint32_t a_alignment) override; // 06
97 
98  // members
99  Pool pools[64]; // 0008
101  std::uint32_t addressSpaceSize; // 1230
102  std::uint32_t pad1234; // 1234
103  char* allocBase; // 1238
104  char* blockPageCommitMin; // 1240
105  char* blockPageCommit; // 1248
108  std::uint32_t totalFreeBlockPages; // 1260
109  bool allowDecommits; // 1264
110  std::uint8_t pad1265; // 1265
111  std::uint16_t pad1266; // 1266
112  };
113  static_assert(sizeof(BSSmallBlockAllocator) == 0x1268);
114 }
Definition: BSAtomic.h:8
Definition: BSSmallBlockAllocator.h:61
std::uint16_t pad1266
Definition: BSSmallBlockAllocator.h:111
MegaBlockPage * megaBlockCurrAlloc
Definition: BSSmallBlockAllocator.h:107
char * allocBase
Definition: BSSmallBlockAllocator.h:103
std::size_t Size(const void *a_block) const override
std::uint32_t addressSpaceSize
Definition: BSSmallBlockAllocator.h:101
void DeallocateAlignImpl(void *&a_freeBlock) override
static constexpr auto RTTI
Definition: BSSmallBlockAllocator.h:63
~BSSmallBlockAllocator() override
std::uint32_t totalFreeBlockPages
Definition: BSSmallBlockAllocator.h:108
std::uint32_t pad1234
Definition: BSSmallBlockAllocator.h:102
bool ContainsBlockImpl(const void *a_block) const override
void GetMemoryStats(MemoryStats *a_stats) override
BSCriticalSection lock
Definition: BSSmallBlockAllocator.h:100
std::uint8_t pad1265
Definition: BSSmallBlockAllocator.h:110
bool allowDecommits
Definition: BSSmallBlockAllocator.h:109
char * blockPageCommit
Definition: BSSmallBlockAllocator.h:105
void * TryAllocateImpl(std::size_t a_size, std::uint32_t a_alignment) override
void * AllocateAlignImpl(std::size_t a_size, std::uint32_t a_alignment) override
Pool pools[64]
Definition: BSSmallBlockAllocator.h:99
MegaBlockPage * megaBlockPageList
Definition: BSSmallBlockAllocator.h:106
char * blockPageCommitMin
Definition: BSSmallBlockAllocator.h:104
Definition: IMemoryStore.h:8
Definition: AbsorbEffect.h:6
constexpr REL::VariantID RTTI_BSSmallBlockAllocator(690291, 398146, 0x1f5f698)
Definition: BSSmallBlockAllocator.h:19
BlockPage * right
Definition: BSSmallBlockAllocator.h:23
BlockPage * left
Definition: BSSmallBlockAllocator.h:22
std::uint32_t pad1C
Definition: BSSmallBlockAllocator.h:27
FreeBlock * blocks
Definition: BSSmallBlockAllocator.h:24
std::uint16_t totalElem
Definition: BSSmallBlockAllocator.h:25
std::uint16_t freeElem
Definition: BSSmallBlockAllocator.h:26
Definition: BSSmallBlockAllocator.h:11
FreeBlock * next
Definition: BSSmallBlockAllocator.h:14
Definition: BSSmallBlockAllocator.h:32
BSCriticalSection lock
Definition: BSSmallBlockAllocator.h:41
std::uint32_t totalBytes
Definition: BSSmallBlockAllocator.h:39
std::uint32_t totalFreeBlocks
Definition: BSSmallBlockAllocator.h:37
std::uint32_t elementSize
Definition: BSSmallBlockAllocator.h:40
BlockPage * currAlloc
Definition: BSSmallBlockAllocator.h:36
BlockPage * pageList
Definition: BSSmallBlockAllocator.h:35
std::uint32_t totalAllocatedBlocks
Definition: BSSmallBlockAllocator.h:38
Definition: BSSmallBlockAllocator.h:72
MegaBlockPage * left
Definition: BSSmallBlockAllocator.h:77
BSSmallBlockAllocatorUtil::BlockPage * freeBlockPages
Definition: BSSmallBlockAllocator.h:79
bool decommitted
Definition: BSSmallBlockAllocator.h:82
char mem[sizeof(BlockPageInternal[255]) *256]
Definition: BSSmallBlockAllocator.h:75
std::uint16_t numFreeBlockPages
Definition: BSSmallBlockAllocator.h:80
std::uint16_t pad1FFFFE
Definition: BSSmallBlockAllocator.h:84
MegaBlockPage * right
Definition: BSSmallBlockAllocator.h:78
std::uint8_t pad1FFFFD
Definition: BSSmallBlockAllocator.h:83
std::uint16_t nextBlockPageAlloc
Definition: BSSmallBlockAllocator.h:81
BlockPageInternal blockPages[255]
Definition: BSSmallBlockAllocator.h:76
Definition: BSSmallBlockAllocator.h:66
Definition: BSSmallBlockAllocator.h:47
std::uint16_t freeElem
Definition: BSSmallBlockAllocator.h:54
std::uint16_t totalElem
Definition: BSSmallBlockAllocator.h:53
BlockPageInternal * left
Definition: BSSmallBlockAllocator.h:50
BSSmallBlockAllocatorUtil::FreeBlock * blocks
Definition: BSSmallBlockAllocator.h:52
BlockPageInternal * right
Definition: BSSmallBlockAllocator.h:51
std::uint16_t elemSize
Definition: BSSmallBlockAllocator.h:55
std::uint16_t check
Definition: BSSmallBlockAllocator.h:56
Definition: IMemoryStoreBase.h:6