3 * Written by Jan Roeloffzen
19 entry_lookup(PLIST list
, char *name
)
21 PLIST_MEMBER pprev
= NULL
;
24 if (!name
|| !name
[0])
30 if (PATHCMP(name
, pnext
->name
) == 0)
33 { // move to head for faster lookup next time
34 pprev
->pnext
= pnext
->pnext
;
35 pnext
->pnext
= list
->phead
;
47 entry_delete(PLIST_MEMBER pentry
)
58 entry_insert(PLIST list
, PLIST_MEMBER pentry
)
63 pentry
->pnext
= list
->phead
;
70 void list_clear(PLIST list
)
72 PLIST_MEMBER pentry
= list
->phead
;
76 pnext
= pentry
->pnext
;
80 list
->phead
= list
->ptail
= NULL
;
85 entry_remove(LIST
*list
, LIST_MEMBER
*pentry
)
87 LIST_MEMBER
*pprev
= NULL
, *p
= NULL
;
92 if (pentry
== list
->phead
)
94 list
->phead
= pentry
->pnext
;
102 if (pprev
->pnext
== pentry
)
104 pprev
->pnext
= pentry
->pnext
;
108 pprev
= pprev
->pnext
;
111 if (pentry
== list
->ptail
)
119 cache_entry_create(char *Line
)
128 pentry
= malloc(sizeof(LIST_MEMBER
));
133 pentry
->buf
= s
= malloc(l
+ 1);
136 l2l_dbg(1, "Alloc entry failed\n");
137 return entry_delete(pentry
);
148 l2l_dbg(1, "Name field missing\n");
149 return entry_delete(pentry
);
157 l2l_dbg(1, "Path field missing\n");
158 return entry_delete(pentry
);
161 if (1 != sscanf(s
, "%x", (unsigned int *)(&pentry
->ImageBase
)))
163 l2l_dbg(1, "ImageBase field missing\n");
164 return entry_delete(pentry
);
166 pentry
->RelBase
= INVALID_BASE
;
173 sources_entry_create(PLIST list
, char *path
, char *prefix
)
184 pentry
= malloc(sizeof(LIST_MEMBER
));
188 l
= strlen(path
) + strlen(prefix
);
189 pentry
->buf
= s
= malloc(l
+ 1);
192 l2l_dbg(1, "Alloc entry failed\n");
193 return entry_delete(pentry
);
204 if (entry_lookup(list
, pentry
->name
))
206 l2l_dbg(1, "Entry %s exists\n", pentry
->name
);
207 pentry
= entry_delete(pentry
);
211 l2l_dbg(1, "Inserting entry %s\n", pentry
->name
);
212 entry_insert(list
, pentry
);