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