Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
HeapCommon.hh
1
#pragma once
2
3
#include "abstract/memory/List.hh"
4
5
#include <egg/core/BitFlag.hh>
6
7
#include <array>
8
9
namespace
Host
{
10
11
class
Context
;
12
13
}
// namespace Host
14
15
namespace
Abstract::Memory {
16
19
class
MEMiHeapHead
{
20
friend
class
Host::Context
;
21
22
public
:
23
enum class
FillType {
24
NoUse = 0,
25
Alloc = 1,
26
Free = 2,
27
};
28
29
enum class
eOptFlag {
30
ZeroFillAlloc = 0,
31
DebugFillAlloc = 1,
32
};
33
typedef
EGG::TBitFlag<u16, eOptFlag>
OptFlag
;
34
35
[[nodiscard]]
MEMList
&getChildList();
36
[[nodiscard]]
void
*getHeapStart();
37
[[nodiscard]]
void
*getHeapEnd();
38
39
[[nodiscard]]
static
MEMList
&getRootList();
40
[[nodiscard]]
static
u32
getFillVal(FillType type);
41
[[nodiscard]]
static
MEMiHeapHead
*findContainHeap(
const
void
*block);
42
43
[[nodiscard]]
static
constexpr
u16
getLinkOffset() {
44
return
offsetof(
MEMiHeapHead
, m_link);
45
}
46
47
protected
:
48
MEMiHeapHead
(
u32
signature,
void
*heapStart,
void
*heapEnd,
const
OptFlag
&opt);
49
~MEMiHeapHead
();
50
51
void
fillNoUseMemory(
void
*address,
u32
size);
52
void
fillAllocMemory(
void
*address,
u32
size);
53
void
fillFreeMemory(
void
*address,
u32
size);
54
55
private
:
56
[[nodiscard]]
static
MEMiHeapHead
*findContainHeap(
MEMList
*list,
const
void
*block);
57
[[nodiscard]]
MEMList
&findListContainHeap()
const
;
58
59
u32
m_signature;
60
OptFlag
m_optFlag;
61
MEMLink
m_link;
62
MEMList
m_childList;
63
void
*m_heapStart;
64
void
*m_heapEnd;
65
66
static
MEMList
s_rootList;
67
static
constexpr
std::array<u32, 3> s_fillVals = {{
68
0xC3C3C3C3,
69
0xF3F3F3F3,
70
0xD3D3D3D3,
71
}};
72
};
73
74
}
// namespace Abstract::Memory
Abstract::Memory::MEMiHeapHead
A low-level representation of a memory heap for managing dynamic memory allocation....
Definition
HeapCommon.hh:19
Host::Context
Contexts can be used to restore a previous memory state for the current session.
Definition
Context.hh:59
uint16_t
uint32_t
Host
Represents the host application.
Definition
HeapCommon.hh:9
Abstract::Memory::MEMLink
Link of an instrusive doubly-linked list.
Definition
List.hh:8
Abstract::Memory::MEMList
Intrusive doubly-linked list. Links are placed within the corresponding object.
Definition
List.hh:14
EGG::TBitFlag
Wrapper around an integral type with an enum corresponding to its bits.
Definition
BitFlag.hh:16
abstract
memory
HeapCommon.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.12.0