X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fca65%2Fulabel.c;h=7748f23dca30d72265e8f8d1b0ed4ed806fc1924;hb=46209118b1a77d2e57f28026b1e5916c2c074778;hp=adfe2e5f177299cadbc6e4a61c5a8580eeecd65e;hpb=53dd513176425872128ef26031d00952ef7a0628;p=cc65 diff --git a/src/ca65/ulabel.c b/src/ca65/ulabel.c index adfe2e5f1..7748f23dc 100644 --- a/src/ca65/ulabel.c +++ b/src/ca65/ulabel.c @@ -33,11 +33,14 @@ -#include "../common/filepos.h" +/* common */ +#include "check.h" +#include "filepos.h" +#include "xmalloc.h" +/* ca65 */ #include "error.h" #include "expr.h" -#include "mem.h" #include "scanner.h" #include "ulabel.h" @@ -50,8 +53,8 @@ /* Struct that describes an unnamed label */ -typedef struct ULabel_ ULabel; -struct ULabel_ { +typedef struct ULabel ULabel; +struct ULabel { ULabel* Prev; /* Pointer to previous node in list */ ULabel* Next; /* Pointer to next node in list */ FilePos Pos; /* Position of the label in the source */ @@ -80,7 +83,7 @@ static ULabel* NewULabel (ExprNode* Val) */ { /* Allocate memory for the ULabel structure */ - ULabel* L = Xmalloc (sizeof (ULabel)); + ULabel* L = xmalloc (sizeof (ULabel)); /* Initialize the fields */ L->Pos = CurPos; @@ -142,14 +145,11 @@ ExprNode* ULabRef (int Which) } else { /* Forward reference. Create labels as needed */ unsigned LabelNum = ULabDefCount + Which - 1; - while (Which > 0) { - if (L->Next == 0) { - NewULabel (0); - } - L = L->Next; - --Which; - } - /* Return an unnamed label expression */ + while (LabelNum < ULabCount) { + NewULabel (0); + } + + /* Return an unnamed label expression */ return ULabelExpr (LabelNum); } } @@ -227,7 +227,7 @@ void ULabCheck (void) */ if (ULabCount) { unsigned I = 0; - ULabList = Xmalloc (ULabCount * sizeof (ULabel*)); + ULabList = xmalloc (ULabCount * sizeof (ULabel*)); L = ULabRoot; while (L) { ULabList[I] = L;