scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit fde68414dfd808d4c6af93543e2ae82e29f05dff
parent 8294c8a407034cd7180d8bdcd921a2b80f532321
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  2 Nov 2019 18:10:46 +0100

[ld] Remove the double linked list for sections

It doesn't add anything and the work can be done in a simpler
way using a single linked list.

Diffstat:
Msrc/cmd/ld/section.c | 13+++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/cmd/ld/section.c b/src/cmd/ld/section.c @@ -20,11 +20,11 @@ struct sectab { Section sec; FILE *tmpfp; struct sectab *hash; - struct sectab *next, *prev; + struct sectab *next; }; static struct sectab *sectab[NR_SECTION]; -static struct sectab secs = {.next = &secs, .prev = &secs}; +static struct sectab *secs; Section * lookupsec(char *name) @@ -60,11 +60,8 @@ lookupsec(char *name) sp->tmpfp = NULL; sp->hash = sectab[h]; sectab[h] = sp; - - sp->next = &secs; - sp->prev = secs.prev; - secs.prev->next = sp; - secs.prev = sp; + sp->next = secs; + secs = sp; return sec; } @@ -76,7 +73,7 @@ merge(Segment *seg) Section *sec, **p; int n = 0; - for (sp = secs.next; sp != &secs; sp = sp->next) { + for (sp = secs; sp; sp = sp->next) { sec = &sp->sec; if (sec->type != seg->type) continue;