]> git.sur5r.net Git - cc65/blobdiff - src/ld65/fragment.c
Removed unneeded include files.
[cc65] / src / ld65 / fragment.c
index 991ed3565f982de80c5fa62b8757664d7644dfe8..3a9e13c7365351609f64259f5f58a74b33efb7e3 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2000 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* (C) 1998-2011, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 
 /* common */
+#include "fragdefs.h"
 #include "xmalloc.h"
 
 /* ld65 */
-#include "segments.h"
+#include "error.h"
 #include "fragment.h"
+#include "objdata.h"
+#include "segments.h"
 
 
 
 
 
 
-Fragment* NewFragment (unsigned char Type, unsigned long Size, Section* S)
+Fragment* NewFragment (unsigned char Type, unsigned Size, Section* S)
 /* Create a new fragment and insert it into the section S */
 {
+    Fragment* F;
+
+    /* Calculate the size of the memory block. LitBuf is only needed if the
+     * fragment contains literal data.
+     */
+    unsigned FragSize = sizeof (Fragment) - 1;
+    if (Type == FRAG_LITERAL) {
+        FragSize += Size;
+    }
+
     /* Allocate memory */
-    Fragment* F = xmalloc (sizeof (Fragment) - 1 + Size);      /* Portable? */
+    F = xmalloc (FragSize);
 
     /* Initialize the data */
-    F->Next = 0;
-    F->Obj  = 0;
-    F->Size = Size;
-    F->Expr = 0;
-    InitFilePos (&F->Pos);
-    F->Type = Type;
+    F->Next      = 0;
+    F->Obj       = 0;
+    F->Sec       = S;
+    F->Size      = Size;
+    F->Expr      = 0;
+    F->LineInfos = EmptyCollection;
+    F->Type      = Type;
 
     /* Insert the code fragment into the section */
     if (S->FragRoot == 0) {