/* Initialize the fields */
S->Name = Name;
S->Next = 0;
- S->SecRoot = 0;
- S->SecLast = 0;
+ S->Sections = EmptyCollection;
S->PC = 0;
S->Size = 0;
S->AlignObj = 0;
S->Offs = Seg->Size; /* Current size is offset */
/* Insert the section into the segment */
- if (Seg->SecRoot == 0) {
- /* First section in this segment */
- Seg->SecRoot = S;
- } else {
- Seg->SecLast->Next = S;
- }
- Seg->SecLast = S;
+ CollAppend (&Seg->Sections, S);
/* Return the struct */
return S;
*/
{
/* Loop over all sections */
- Section* Sec = S->SecRoot;
- while (Sec) {
+ unsigned I;
+ for (I = 0; I < CollCount (&S->Sections); ++I) {
+
+ /* Get the next section */
+ Section* Sec = CollAtUnchecked (&S->Sections, I);
+
/* Loop over all fragments */
Fragment* F = Sec->FragRoot;
while (F) {
}
F = F->Next;
}
- Sec = Sec->Next;
}
return 1;
}
void SegDump (void)
/* Dump the segments and it's contents */
{
- unsigned I;
+ unsigned I, J;
unsigned long Count;
unsigned char* Data;
for (I = 0; I < CollCount (&SegmentList); ++I) {
- const Segment* Seg = CollConstAt (&SegmentList, I);
- Section* S = Seg->SecRoot;
+ Segment* Seg = CollAtUnchecked (&SegmentList, I);
printf ("Segment: %s (%lu)\n", GetString (Seg->Name), Seg->Size);
- while (S) {
+ for (J = 0; J < CollCount (&Seg->Sections); ++J) {
+ Section* S = CollAtUnchecked (&Seg->Sections, J);
unsigned J;
Fragment* F = S->FragRoot;
printf (" Section:\n");
}
F = F->Next;
}
- S = S->Next;
}
}
}
* called (see description of SegWriteFunc above).
*/
{
- Section* Sec;
+ unsigned I;
int Sign;
unsigned long Offs = 0;
S->OutputOffs = (unsigned long) ftell (Tgt);
/* Loop over all sections in this segment */
- Sec = S->SecRoot;
- while (Sec) {
+ for (I = 0; I < CollCount (&S->Sections); ++I) {
+ Section* Sec = CollAtUnchecked (&S->Sections, I);
Fragment* Frag;
/* Output were this section is from */
/* Next fragment */
Frag = Frag->Next;
}
-
- /* Next section */
- Sec = Sec->Next;
}
}
#include <stdio.h>
-/* common */
+/* common */
+#include "coll.h"
#include "exprdefs.h"
struct Segment {
unsigned Name; /* Name index of the segment */
unsigned Id; /* Segment id for debug info */
- Segment* Next; /* Hash list */
- struct Section* SecRoot; /* Section list */
- struct Section* SecLast; /* Pointer to last section */
+ Segment* Next; /* Hash list */
+ Collection Sections; /* Sections in this segment */
unsigned long PC; /* PC were this segment is located */
unsigned long Size; /* Size of data so far */
struct ObjData* AlignObj; /* Module that requested the alignment */