]> git.sur5r.net Git - cc65/commitdiff
Use collections in the object file structure instead of managing the items
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 30 Jul 2010 20:58:51 +0000 (20:58 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 30 Jul 2010 20:58:51 +0000 (20:58 +0000)
manually.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4773 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ld65/dbginfo.c
src/ld65/dbgsyms.c
src/ld65/dbgsyms.h
src/ld65/expr.c
src/ld65/library.c
src/ld65/lineinfo.c
src/ld65/mapfile.c
src/ld65/objdata.c
src/ld65/objdata.h
src/ld65/objfile.c
src/ld65/segments.c

index e2725b4fdd69c253936f449a40e92d7b1274afb7..8af831ba3e9bc8836ecaa2ef85c71423f81e8b4b 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2001-2008 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2001-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -53,17 +53,17 @@ void PrintDbgInfo (ObjData* O, FILE* F)
     unsigned I, J;
 
     /* Output the files section */
-    for (I = 0; I < O->FileCount; ++I) {
-       const FileInfo* FI = O->Files[I];
+    for (I = 0; I < CollCount (&O->Files); ++I) {
+       const FileInfo* FI = CollConstAt (&O->Files, I);
        fprintf (F, "file\t\"%s\",size=%lu,mtime=0x%08lX\n",
                  GetString (FI->Name), FI->Size, FI->MTime);
     }
 
     /* Output the line infos */
-    for (I = 0; I < O->LineInfoCount; ++I) {
+    for (I = 0; I < CollCount (&O->LineInfos); ++I) {
 
        /* Get this line info */
-       const LineInfo* LI = O->LineInfos[I];
+       const LineInfo* LI = CollConstAt (&O->LineInfos, I);
 
        /* Get a pointer to the code ranges */
        const Collection* CodeRanges = &LI->CodeRanges;
index 661ced0847ce7c45ee39cd7ce6a1f71c811039a3..f52e082d75d99283e9a396c6f59f07c984bdda89 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2008 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -82,7 +82,7 @@ static DbgSym* NewDbgSym (unsigned char Type, unsigned char AddrSize, ObjData* O
     D->Flags   = 0;
     D->Obj      = O;
     D->Expr            = 0;
-    D->Name    = 0;
+    D->Name    = 0;
     D->Type            = Type;
     D->AddrSize = AddrSize;
 
@@ -99,9 +99,9 @@ static DbgSym* GetDbgSym (DbgSym* D, long Val)
 {
     /* Create the hash. We hash over the symbol value */
     unsigned Hash = ((Val >> 24) & 0xFF) ^
-                   ((Val >> 16) & 0xFF) ^
-                   ((Val >>  8) & 0xFF) ^
-                   ((Val >>  0) & 0xFF);
+                   ((Val >> 16) & 0xFF) ^
+                   ((Val >>  8) & 0xFF) ^
+                   ((Val >>  0) & 0xFF);
 
     /* Check for this symbol */
     DbgSym* Sym = DbgSymPool[Hash];
@@ -184,7 +184,7 @@ void ClearDbgSymTable (void)
 
 
 
-long GetDbgSymVal (DbgSym* D)
+long GetDbgSymVal (const DbgSym* D)
 /* Get the value of this symbol */
 {
     CHECK (D->Expr != 0);
@@ -199,12 +199,12 @@ void PrintDbgSyms (ObjData* O, FILE* F)
     unsigned I;
 
     /* Walk through all debug symbols in this module */
-    for (I = 0; I < O->DbgSymCount; ++I) {
+    for (I = 0; I < CollCount (&O->DbgSyms); ++I) {
 
        long Val;
 
        /* Get the next debug symbol */
-       DbgSym* D = O->DbgSyms [I];
+       DbgSym* D = CollAt (&O->DbgSyms, I);
 
        /* Get the symbol value */
        Val = GetDbgSymVal (D);
@@ -237,12 +237,12 @@ void PrintDbgSymLabels (ObjData* O, FILE* F)
     unsigned I;
 
     /* Walk through all debug symbols in this module */
-    for (I = 0; I < O->DbgSymCount; ++I) {
+    for (I = 0; I < CollCount (&O->DbgSyms); ++I) {
 
        long Val;
 
        /* Get the next debug symbol */
-       DbgSym* D = O->DbgSyms [I];
+       DbgSym* D = CollAt (&O->DbgSyms, I);
 
         /* Emit this symbol only if it is a label (ignore equates) */
         if (IS_EXP_EQUATE (D->Type)) {
index 6a3e5cfa65cb0165b3650c15eef443de1e1226c9..5ad169453f91a3c5f2deaf580910a47b164e9ea9 100644 (file)
@@ -79,7 +79,7 @@ struct DbgSym {
 DbgSym* ReadDbgSym (FILE* F, ObjData* Obj);
 /* Read a debug symbol from a file, insert and return it */
 
-long GetDbgSymVal (DbgSym* D);
+long GetDbgSymVal (const DbgSym* D);
 /* Get the value of this symbol */
 
 void ClearDbgSymTable (void);
index faa9bbde56aaffd5e50955298bdd852770e4fd4c..94f910d7acfe54d78700eeff71f8fe5b236c6e55 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2007 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -201,7 +201,7 @@ Import* GetExprImport (ExprNode* Expr)
     PRECONDITION (Expr->Op == EXPR_SYMBOL);
 
     /* Return the import */
-    return Expr->Obj->Imports [Expr->V.ImpNum];
+    return CollAt (&Expr->Obj->Imports, Expr->V.ImpNum);
 }
 
 
@@ -212,8 +212,8 @@ Export* GetExprExport (ExprNode* Expr)
     /* Check that this is really a symbol */
     PRECONDITION (Expr->Op == EXPR_SYMBOL);
 
-    /* Return the export */
-    return Expr->Obj->Imports [Expr->V.ImpNum]->Exp;
+    /* Return the export for an import*/
+    return GetExprImport (Expr)->Exp;
 }
 
 
@@ -230,7 +230,7 @@ Section* GetExprSection (ExprNode* Expr)
      */
     if (Expr->Obj) {
        /* Return the export */
-       return Expr->Obj->Sections[Expr->V.SegNum];
+               return CollAt (&Expr->Obj->Sections, Expr->V.SegNum);
     } else {
        return Expr->V.Sec;
     }
@@ -343,7 +343,7 @@ long GetExprVal (ExprNode* Expr)
 
        case EXPR_BOOLXOR:
            return (GetExprVal (Expr->Left) != 0) ^ (GetExprVal (Expr->Right) != 0);
-                  
+
         case EXPR_MAX:
             Left = GetExprVal (Expr->Left);
             Right = GetExprVal (Expr->Right);
index 0086c212f6424b86f41e6459417006f90249ef7b..228f6c2ee7ee3d68502f1343502eadee55f54f28 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                          */
 /*                                                                          */
 /*                                                                          */
-/* (C) 1998-2005 Ullrich von Bassewitz                                       */
-/*               Römerstraße 52                                              */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                          */
 /*                                                                          */
 /* This software is provided 'as-is', without any expressed or implied      */
@@ -259,17 +259,15 @@ static void LibCheckExports (ObjData* O)
     unsigned I;
 
     /* Check all exports */
-    for (I = 0; I < O->ExportCount; ++I) {
-       if (IsUnresolved (O->Exports[I]->Name)) {
-           /* We need this module */
-           O->Flags |= OBJ_REF;            break;
+    for (I = 0; I < CollCount (&O->Exports); ++I) {
+        const Export* E = CollConstAt (&O->Exports, I);
+       if (IsUnresolved (E->Name)) {
+           /* We need this module, insert the imports and exports */
+           O->Flags |= OBJ_REF;
+            InsertObjGlobals (O);
+            break;
        }
     }
-
-    /* If we need this module, insert the imports and exports */
-    if (O->Flags & OBJ_REF) {
-        InsertObjGlobals (O);
-    }
 }
 
 
index 92374f9742bc4201a604958630c31236d9a5f999..2db2057821a3428e88025c26f51028709dfebd65 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2001      Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2001-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -95,8 +95,8 @@ LineInfo* ReadLineInfo (FILE* F, ObjData* O)
     ReadFilePos (F, &LI->Pos);
 
     /* Resolve the file index to a pointer to FileInfo struct */
-    CHECK (LI->Pos.Name < O->FileCount);
-    LI->File = O->Files[LI->Pos.Name];
+    CHECK (LI->Pos.Name < CollCount (&O->Files));
+    LI->File = CollAt (&O->Files, LI->Pos.Name);
 
     /* Return the new LineInfo */
     return LI;
@@ -189,3 +189,4 @@ void RelocLineInfo (Segment* S)
 
 
 
+
index c1bc4cf90e6e5e074853d7938c313e88e4d83e71..d7d90e2d623eecb6ab82bacbba1b1d948a6a8034 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2005 Ullrich von Bassewitz                                       */
-/*               Römerstraße 52                                              */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -86,8 +86,8 @@ void CreateMapFile (int ShortMap)
         } else {
             fprintf (F, "%s:\n", GetObjFileName (O));
         }
-        for (J = 0; J < O->SectionCount; ++J) {
-            const Section* S = O->Sections [J];
+        for (J = 0; J < CollCount (&O->Sections); ++J) {
+            const Section* S = CollConstAt (&O->Sections, J);
             /* Don't include zero sized sections if not explicitly
              * requested
              */
index ebdf3948f9b05d515c095e0aa9118582ee930387..3365b665f54365905a1f6f9367f0109ea0f1046b 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Römerstraße 52                                              */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -49,7 +49,7 @@
 
 
 /*****************************************************************************/
-/*                                          Data                                    */
+/*                                          Data                                    */
 /*****************************************************************************/
 
 
@@ -60,7 +60,7 @@ Collection       ObjDataList = STATIC_COLLECTION_INITIALIZER;
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                          Code                                    */
 /*****************************************************************************/
 
 
@@ -79,19 +79,19 @@ ObjData* NewObjData (void)
     O->Flags                   = 0;
     O->Start           = 0;
     O->ExportCount     = 0;
-    O->Exports         = 0;
+    O->Exports         = EmptyCollection;
     O->ImportCount     = 0;
-    O->Imports         = 0;
+    O->Imports         = EmptyCollection;
     O->DbgSymCount     = 0;
-    O->DbgSyms         = 0;
+    O->DbgSyms         = EmptyCollection;
     O->LineInfoCount    = 0;
-    O->LineInfos        = 0;
+    O->LineInfos        = EmptyCollection;
     O->StringCount      = 0;
     O->Strings          = 0;
     O->AssertionCount   = 0;
-    O->Assertions       = 0;
+    O->Assertions       = EmptyCollection;
     O->ScopeCount       = 0;
-    O->Scopes           = 0;
+    O->Scopes           = EmptyCollection;
 
     /* Return the new entry */
     return O;
@@ -105,16 +105,22 @@ void FreeObjData (ObjData* O)
  * referenced.
  */
 {
+    unsigned I;
+
     /* Unused ObjData do only have the string pool, Exports and Imports. */
-    while (O->ExportCount) {
-        FreeExport (O->Exports[--O->ExportCount]);
+    for (I = 0; I < CollCount (&O->Exports); ++I) {
+        FreeExport (CollAt (&O->Exports, I));
     }
-    xfree (O->Exports);
-    while (O->ImportCount) {
-        FreeImport (O->Imports[--O->ImportCount]);
+    DoneCollection (&O->Exports);
+    for (I = 0; I < CollCount (&O->Imports); ++I) {
+        FreeImport (CollAt (&O->Imports, I));
     }
-    xfree (O->Imports);
+    DoneCollection (&O->Imports);
+    DoneCollection (&O->DbgSyms);
+    DoneCollection (&O->LineInfos);
     xfree (O->Strings);
+    DoneCollection (&O->Assertions);
+    DoneCollection (&O->Scopes);
     xfree (O);
 }
 
@@ -147,11 +153,11 @@ void InsertObjGlobals (ObjData* O)
     unsigned I;
 
     /* Insert exports and imports */
-    for (I = 0; I < O->ExportCount; ++I) {
-        InsertExport (O->Exports[I]);
+    for (I = 0; I < CollCount (&O->Exports); ++I) {
+        InsertExport (CollAt (&O->Exports, I));
     }
-    for (I = 0; I < O->ImportCount; ++I) {
-        InsertImport (O->Imports[I]);
+    for (I = 0; I < CollCount (&O->Imports); ++I) {
+        InsertImport (CollAt (&O->Imports, I));
     }
 }
 
@@ -193,16 +199,21 @@ const char* GetSourceFileName (const ObjData* O, unsigned Index)
     } else {
 
        /* Check the parameter */
-        if (Index >= O->FileCount) {
+        if (Index >= CollCount (&O->Files)) {
             /* Error() will terminate the program */
             Warning ("Invalid file index (%u) in module `%s' (input file corrupt?)",
                    Index, GetObjFileName (O));
             return "[invalid]";         /* ### */
-        }
 
-       /* Return the name */
-       return GetString (O->Files[Index]->Name);
+        } else {
 
+            /* Get a pointer to the file info struct */
+            const FileInfo* FI = CollAt (&O->Files, Index);
+
+            /* Return the name */
+            return GetString (FI->Name);
+
+        }
     }
 }
 
index e538320aaf1291175039ddd2504dcf388713d98f..ca39f38a09e5aba46ad6a387f024c087ebc5e395 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Römerstraße 52                                              */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -65,23 +65,23 @@ struct ObjData {
     unsigned long      Start;          /* Start offset of data in library */
     unsigned           Flags;
     unsigned           FileCount;      /* Input file count */
-    struct FileInfo**          Files;          /* List of input files */
+    Collection          Files;         /* List of input files */
     unsigned           SectionCount;   /* Count of sections in this object */
-    struct Section**   Sections;       /* List of all sections */
+    Collection          Sections;      /* List of all sections */
     unsigned           ExportCount;    /* Count of exports */
-    struct Export**    Exports;        /* List of all exports */
+    Collection          Exports;               /* List of all exports */
     unsigned           ImportCount;    /* Count of imports */
-    struct Import**    Imports;        /* List of all imports */
+    Collection          Imports;       /* List of all imports */
     unsigned           DbgSymCount;    /* Count of debug symbols */
-    struct DbgSym**    DbgSyms;        /* List of debug symbols */
+    Collection          DbgSyms;               /* List of debug symbols */
     unsigned            LineInfoCount;  /* Count of additional line infos */
-    struct LineInfo**   LineInfos;      /* List of additional line infos */
+    Collection          LineInfos;      /* List of additional line infos */
     unsigned            StringCount;    /* Count of strings */
     unsigned*           Strings;        /* List of global string indices */
     unsigned            AssertionCount; /* Count of module assertions */
-    struct Assertion**  Assertions;     /* List of module assertions */
+    Collection          Assertions;     /* List of module assertions */
     unsigned            ScopeCount;     /* Count of scopes */
-    struct Scope**      Scopes;         /* List of scopes */
+    Collection          Scopes;         /* List of scopes */
 };
 
 
@@ -131,10 +131,10 @@ const char* GetObjFileName (const ObjData* O);
 INLINE int ObjHasFiles (const ObjData* O)
 /* Return true if the files list does exist */
 {
-    return (O != 0 && O->Files != 0);
+    return (O != 0 && CollCount (&O->Files) != 0);
 }
 #else
-#  define ObjHasFiles(O)       ((O) != 0 && (O)->Files != 0)
+#  define ObjHasFiles(O)       ((O) != 0 && CollCount ((O)->Files) != 0)
 #endif
 
 const char* GetSourceFileName (const ObjData* O, unsigned Index);
index bea9fda6932f6a0f08216c6881ed5ade904cf4bb..0de4c70eecf03ec850dfa9eb4b8ab88f879a18be 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                          */
 /*                                                                          */
 /*                                                                          */
-/* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Römerstraße 52                                              */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                          */
 /*                                                                          */
 /* This software is provided 'as-is', without any expressed or implied      */
@@ -120,9 +120,9 @@ void ObjReadFiles (FILE* F, unsigned long Pos, ObjData* O)
 
     /* Read the data */
     O->FileCount  = ReadVar (F);
-    O->Files      = xmalloc (O->FileCount * sizeof (O->Files[0]));
+    CollGrow (&O->Files, O->FileCount);
     for (I = 0; I < O->FileCount; ++I) {
-               O->Files[I] = ReadFileInfo (F, O);
+               CollAppend (&O->Files, ReadFileInfo (F, O));
     }
 }
 
@@ -138,9 +138,9 @@ void ObjReadSections (FILE* F, unsigned long Pos, ObjData* O)
 
     /* Read the data */
     O->SectionCount = ReadVar (F);
-    O->Sections     = xmalloc (O->SectionCount * sizeof (O->Sections[0]));
+    CollGrow (&O->Sections, O->SectionCount);
     for (I = 0; I < O->SectionCount; ++I) {
-       O->Sections [I] = ReadSection (F, O);
+               CollAppend (&O->Sections, ReadSection (F, O));
     }
 }
 
@@ -156,9 +156,9 @@ void ObjReadImports (FILE* F, unsigned long Pos, ObjData* O)
 
     /* Read the data */
     O->ImportCount = ReadVar (F);
-    O->Imports     = xmalloc (O->ImportCount * sizeof (O->Imports[0]));
+    CollGrow (&O->Imports, O->ImportCount);
     for (I = 0; I < O->ImportCount; ++I) {
-       O->Imports [I] = ReadImport (F, O);
+               CollAppend (&O->Imports, ReadImport (F, O));
     }
 }
 
@@ -174,9 +174,9 @@ void ObjReadExports (FILE* F, unsigned long Pos, ObjData* O)
 
     /* Read the data */
     O->ExportCount = ReadVar (F);
-    O->Exports     = xmalloc (O->ExportCount * sizeof (O->Exports[0]));
+    CollGrow (&O->Exports, O->ExportCount);
     for (I = 0; I < O->ExportCount; ++I) {
-       O->Exports [I] = ReadExport (F, O);
+               CollAppend (&O->Exports, ReadExport (F, O));
     }
 }
 
@@ -192,9 +192,9 @@ void ObjReadDbgSyms (FILE* F, unsigned long Pos, ObjData* O)
 
     /* Read the data */
     O->DbgSymCount = ReadVar (F);
-    O->DbgSyms    = xmalloc (O->DbgSymCount * sizeof (O->DbgSyms[0]));
+    CollGrow (&O->DbgSyms, O->DbgSymCount);
     for (I = 0; I < O->DbgSymCount; ++I) {
-       O->DbgSyms [I] = ReadDbgSym (F, O);
+       CollAppend (&O->DbgSyms, ReadDbgSym (F, O));
     }
 }
 
@@ -210,9 +210,9 @@ void ObjReadLineInfos (FILE* F, unsigned long Pos, ObjData* O)
 
     /* Read the data */
     O->LineInfoCount = ReadVar (F);
-    O->LineInfos     = xmalloc (O->LineInfoCount * sizeof (O->LineInfos[0]));
+    CollGrow (&O->LineInfos, O->LineInfoCount);
     for (I = 0; I < O->LineInfoCount; ++I) {
-               O->LineInfos[I] = ReadLineInfo (F, O);
+               CollAppend (&O->LineInfos, ReadLineInfo (F, O));
     }
 }
 
@@ -246,9 +246,9 @@ void ObjReadAssertions (FILE* F, unsigned long Pos, ObjData* O)
 
     /* Read the data */
     O->AssertionCount = ReadVar (F);
-    O->Assertions     = xmalloc (O->AssertionCount * sizeof (O->Assertions[0]));
+    CollGrow (&O->Assertions, O->AssertionCount);
     for (I = 0; I < O->AssertionCount; ++I) {
-        O->Assertions[I] = ReadAssertion (F, O);
+        CollAppend (&O->Assertions, ReadAssertion (F, O));
     }
 }
 
@@ -264,9 +264,9 @@ void ObjReadScopes (FILE* F, unsigned long Pos, ObjData* O)
 
     /* Read the data */
     O->ScopeCount = ReadVar (F);
-    O->Scopes     = xmalloc (O->ScopeCount * sizeof (O->Scopes[0]));
+    CollGrow (&O->Scopes, O->ScopeCount);
     for (I = 0; I < O->ScopeCount; ++I) {
-        O->Scopes[I] = 0;       /* ReadScope (F, O); ### not implemented */
+        CollAppend (&O->Scopes, 0);     /* ReadScope (F, O); ### not implemented */
     }
 }
 
index 1fb7fcbd792d16e58fc3e8dfcf57ff23338edb81..11943dc772c877e6d3150362d67027d185b5816a 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2003 Ullrich von Bassewitz                                       */
-/*               Römerstraße 52                                              */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -276,15 +276,16 @@ Section* ReadSection (FILE* F, ObjData* O)
        LineInfoIndex = ReadVar (F);
        if (LineInfoIndex) {
            --LineInfoIndex;
-           if (LineInfoIndex >= O->LineInfoCount) {
+           if (LineInfoIndex >= CollCount (&O->LineInfos)) {
                        Internal ("In module `%s', file `%s', line %lu: Invalid line "
                          "info with index %u (max count %u)",
                          GetObjFileName (O),
                          GetSourceFileName (O, Frag->Pos.Name),
-                                 Frag->Pos.Line, LineInfoIndex, O->LineInfoCount);
+                                 Frag->Pos.Line, LineInfoIndex, 
+                          CollCount (&O->LineInfos));
            }
            /* Point from the fragment to the line info... */
-           Frag->LI = O->LineInfos[LineInfoIndex];
+           Frag->LI = CollAt (&O->LineInfos, LineInfoIndex);
            /* ...and back from the line info to the fragment */
            CollAppend (&Frag->LI->Fragments, Frag);
        }