3namespace Abstract::Memory {
6MEMList::MEMList(
u16 offset) {
7 m_headObject =
nullptr;
8 m_tailObject =
nullptr;
14void MEMList::append(
void *
object) {
18 setFirstObject(
object);
20 MEMLink *link = getLink(
object);
22 link->m_prevObject = m_tailObject;
23 link->m_nextObject =
nullptr;
25 getLink(m_tailObject)->m_nextObject = object;
26 m_tailObject = object;
32void MEMList::remove(
void *
object) {
35 MEMLink *link = getLink(
object);
37 if (!link->m_prevObject) {
38 m_headObject = link->m_nextObject;
40 getLink(link->m_prevObject)->m_nextObject = link->m_nextObject;
43 if (!link->m_nextObject) {
44 m_tailObject = link->m_prevObject;
46 getLink(link->m_nextObject)->m_prevObject = link->m_prevObject;
49 link->m_prevObject =
nullptr;
50 link->m_nextObject =
nullptr;
54void *MEMList::getFirst() {
55 return getNext(
nullptr);
59void *MEMList::getNext(
void *
object) {
60 return object ? getLink(
object)->m_nextObject : m_headObject;
63void MEMList::setFirstObject(
void *
object) {
66 MEMLink *link = getLink(
object);
68 link->m_nextObject =
nullptr;
69 link->m_prevObject =
nullptr;
71 m_headObject = object;
72 m_tailObject = object;
76MEMLink *MEMList::getLink(
void *
object) {
77 return reinterpret_cast<MEMLink *
>(GetAddrNum(
object) + m_offset);