From: uz Date: Sun, 8 Aug 2010 15:23:22 +0000 (+0000) Subject: More collection usage. X-Git-Tag: V2.13.3~657 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fedb265a2299e629e96707c3790428f453f1cd23;p=cc65 More collection usage. git-svn-id: svn://svn.cc65.org/cc65/trunk@4794 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ld65/config.c b/src/ld65/config.c index d54e1f632..04caa0954 100644 --- a/src/ld65/config.c +++ b/src/ld65/config.c @@ -98,8 +98,7 @@ static Collection MemoryList = STATIC_COLLECTION_INITIALIZER; /* Segment list */ -SegDesc* SegDescList; /* Single linked list */ -unsigned SegDescCount; /* Number of entries in list */ +static Collection SegDescList = STATIC_COLLECTION_INITIALIZER; /* Segment attributes */ #define SA_TYPE 0x0001 @@ -179,7 +178,7 @@ static Memory* CfgFindMemory (unsigned Name) { unsigned I; for (I = 0; I < CollCount (&MemoryList); ++I) { - Memory* M = CollAt (&MemoryList, I); + Memory* M = CollAtUnchecked (&MemoryList, I); if (M->Name == Name) { return M; } @@ -204,13 +203,13 @@ static Memory* CfgGetMemory (unsigned Name) static SegDesc* CfgFindSegDesc (unsigned Name) /* Find the segment descriptor with the given name, return NULL if not found. */ { - SegDesc* S = SegDescList; - while (S) { + unsigned I; + for (I = 0; I < CollCount (&SegDescList); ++I) { + SegDesc* S = CollAtUnchecked (&SegDescList, I); if (S->Name == Name) { /* Found */ return S; } - S = S->Next; } /* Not found */ @@ -223,9 +222,7 @@ static void SegDescInsert (SegDesc* S) /* Insert a segment descriptor into the list of segment descriptors */ { /* Insert the struct into the list */ - S->Next = SegDescList; - SegDescList = S; - ++SegDescCount; + CollAppend (&SegDescList, S); } @@ -331,7 +328,6 @@ static SegDesc* NewSegDesc (unsigned Name) /* Initialize the fields */ S->Name = Name; - S->Next = 0; S->Seg = Seg; S->Attr = 0; S->Flags = 0; @@ -1744,7 +1740,7 @@ void CfgWriteTarget (void) /* No output file. Walk through the list and mark all segments * loading into these memory areas in this file as dumped. - */ + */ unsigned J; for (J = 0; J < CollCount (&F->MemList); ++J) { diff --git a/src/ld65/config.h b/src/ld65/config.h index 49fe786bb..3693d76ac 100644 --- a/src/ld65/config.h +++ b/src/ld65/config.h @@ -88,7 +88,6 @@ struct Memory { typedef struct SegDesc SegDesc; struct SegDesc { unsigned Name; /* Index of the name */ - SegDesc* Next; /* Pointer to next entry in list */ Segment* Seg; /* Pointer to segment structure */ unsigned Attr; /* Attributes for segment */ unsigned Flags; /* Set of bitmapped flags */ @@ -99,10 +98,6 @@ struct SegDesc { unsigned char AlignLoad; /* Load area alignment if given */ }; -/* Segment list */ -extern SegDesc* SegDescList; /* Single linked list */ -extern unsigned SegDescCount; /* Number of entries in list */ - /* Memory flags */ #define MF_DEFINE 0x0001 /* Define start and size */ #define MF_FILL 0x0002 /* Fill segment */