X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fld65%2Ffragment.c;h=3a9e13c7365351609f64259f5f58a74b33efb7e3;hb=35e1184901ca38bdb2e56d154ed3b71f6096eacc;hp=cd4ae6028d1654d0ec051a9680b49c1fc4601482;hpb=76e67e2f971944cbca0f06642684ad1c45587e28;p=cc65 diff --git a/src/ld65/fragment.c b/src/ld65/fragment.c index cd4ae6028..3a9e13c73 100644 --- a/src/ld65/fragment.c +++ b/src/ld65/fragment.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2003 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (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 */ @@ -34,11 +34,14 @@ /* common */ +#include "fragdefs.h" #include "xmalloc.h" /* ld65 */ -#include "segments.h" +#include "error.h" #include "fragment.h" +#include "objdata.h" +#include "segments.h" @@ -48,21 +51,29 @@ -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); + F = xmalloc (FragSize); /* Initialize the data */ F->Next = 0; F->Obj = 0; + F->Sec = S; F->Size = Size; F->Expr = 0; - InitFilePos (&F->Pos); - F->LI = 0; - F->WarnExpr = 0; - F->ErrorExpr = 0; + F->LineInfos = EmptyCollection; F->Type = Type; /* Insert the code fragment into the section */