-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtListHandler.c
More file actions
57 lines (44 loc) · 1.01 KB
/
ExtListHandler.c
File metadata and controls
57 lines (44 loc) · 1.01 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "declarationsHeader.h"
extern extPtr extListHead;
/*
* Add the passed symbol to the extern list.
*/
void addToExtList(char *sym) {
static extPtr last;
extPtr newExtSym = (extPtr) malloc(sizeof(extNode));
MEMORY_ERROR(newExtSym)
strcpy(newExtSym->symbol, sym);
newExtSym->updated = FALSE;
newExtSym->next = NULL;
if (extListHead == NULL) {
extListHead = newExtSym;
last = extListHead;
} else {
last->next = newExtSym;
last = last->next;
}
}
/*
* Updates the address's of the extern symbols.
*/
void updateExtList(int address) {
extPtr exPtr;
for (exPtr = extListHead; exPtr; exPtr = exPtr->next) {
if (!exPtr->updated) {
exPtr->address = address;
exPtr->updated = TRUE;
return;
}
}
}
/*
* Frees the extern list.
*/
void freeExtList() {
extPtr p;
while (extListHead != NULL) {
p = extListHead;
extListHead = extListHead->next;
free(p);
}
}