blob: 54f8ca9bdcf2aef2af5569d6b9c14de44abf6b0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <revolution/mem/list.h>
// I've tried inlines but only a macro seems to work
#define GetLink(parent_list, obj) ((MEMLink*)(((u32)(obj))+(parent_list)->offs))
void MEMInitList(MEMList *pList, u16 offs) {
pList->head = NULL;
pList->tail = NULL;
pList->num = 0;
pList->offs = offs;
}
void MEMAppendListObject(MEMList *pList, void *pObj) {
MEMLink* link;
if (pList->head == NULL) {
link = GetLink(pList, pObj);
link->next = NULL;
link->prev = NULL;
pList->head = pObj;
pList->tail = pObj;
pList->num++;
}
else {
link = GetLink(pList, pObj);
link->prev = pList->tail;
link->next = NULL;
GetLink(pList, pList->tail)->next = pObj;
pList->tail = pObj;
pList->num++;
}
}
void* MEMGetNextListObject(MEMList *pList, void *pObj) {
if (pObj == NULL) {
return pList->head;
}
return GetLink(pList, pObj)->next;
}
|