mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 02:03:03 +00:00
(yyinitGLRStack, yyreturn): Don't call malloc again if the first call
fails.
This commit is contained in:
42
data/glr.c
42
data/glr.c
@@ -1018,11 +1018,14 @@ yyinitGLRStack (yyGLRStack* yystack, size_t yysize)
|
|||||||
yystack->yyerrState = 0;
|
yystack->yyerrState = 0;
|
||||||
yynerrs = 0;
|
yynerrs = 0;
|
||||||
yystack->yyspaceLeft = yysize;
|
yystack->yyspaceLeft = yysize;
|
||||||
yystack->yynextFree = yystack->yyitems =
|
yystack->yyitems =
|
||||||
(yyGLRStackItem*) YYMALLOC (yysize * sizeof yystack->yynextFree[0]);
|
(yyGLRStackItem*) YYMALLOC (yysize * sizeof yystack->yynextFree[0]);
|
||||||
|
if (!yystack->yyitems)
|
||||||
|
return yyfalse;
|
||||||
|
yystack->yynextFree = yystack->yyitems;
|
||||||
yystack->yysplitPoint = NULL;
|
yystack->yysplitPoint = NULL;
|
||||||
yystack->yylastDeleted = NULL;
|
yystack->yylastDeleted = NULL;
|
||||||
return yyinitStateSet (&yystack->yytops) && yystack->yyitems;
|
return yyinitStateSet (&yystack->yytops);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
|
#define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
|
||||||
@@ -2154,24 +2157,27 @@ b4_syncline([@oline@], [@ofile@])])dnl
|
|||||||
yydestruct ("Error: discarding lookahead",
|
yydestruct ("Error: discarding lookahead",
|
||||||
yytoken, yylvalp]b4_location_if([, yyllocp])[);
|
yytoken, yylvalp]b4_location_if([, yyllocp])[);
|
||||||
|
|
||||||
/* Now pop stack until empty, destroying its entries as we go. */
|
/* If the stack is well-formed, pop the stack until it is empty,
|
||||||
{
|
destroying its entries as we go. But free the stack regardless
|
||||||
yyGLRState** yystates = yystack.yytops.yystates;
|
of whether it is well-formed. */
|
||||||
if (yystates)
|
if (yystack.yyitems)
|
||||||
while (yystates[0])
|
{
|
||||||
{
|
yyGLRState** yystates = yystack.yytops.yystates;
|
||||||
yyGLRState *yys = yystates[0];
|
if (yystates)
|
||||||
|
while (yystates[0])
|
||||||
|
{
|
||||||
|
yyGLRState *yys = yystates[0];
|
||||||
]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
|
]b4_location_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
|
||||||
)[ yydestruct ("Error: popping",
|
)[ yydestruct ("Error: popping",
|
||||||
yystos[yys->yylrState],
|
yystos[yys->yylrState],
|
||||||
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
||||||
yystates[0] = yys->yypred;
|
yystates[0] = yys->yypred;
|
||||||
yystack.yynextFree -= 1;
|
yystack.yynextFree -= 1;
|
||||||
yystack.yyspaceLeft += 1;
|
yystack.yyspaceLeft += 1;
|
||||||
}
|
}
|
||||||
}
|
yyfreeGLRStack (&yystack);
|
||||||
|
}
|
||||||
|
|
||||||
yyfreeGLRStack (&yystack);
|
|
||||||
return yyresult;
|
return yyresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user