(yyinitGLRStack, yyreturn): Don't call malloc again if the first call

fails.
This commit is contained in:
Paul Eggert
2005-07-22 04:56:14 +00:00
parent 9cbfdc9e01
commit 3922956abd

View File

@@ -1018,11 +1018,14 @@ yyinitGLRStack (yyGLRStack* yystack, size_t yysize)
yystack->yyerrState = 0;
yynerrs = 0;
yystack->yyspaceLeft = yysize;
yystack->yynextFree = yystack->yyitems =
yystack->yyitems =
(yyGLRStackItem*) YYMALLOC (yysize * sizeof yystack->yynextFree[0]);
if (!yystack->yyitems)
return yyfalse;
yystack->yynextFree = yystack->yyitems;
yystack->yysplitPoint = NULL;
yystack->yylastDeleted = NULL;
return yyinitStateSet (&yystack->yytops) && yystack->yyitems;
return yyinitStateSet (&yystack->yytops);
}
#define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
@@ -2154,7 +2157,10 @@ b4_syncline([@oline@], [@ofile@])])dnl
yydestruct ("Error: discarding lookahead",
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
of whether it is well-formed. */
if (yystack.yyitems)
{
yyGLRState** yystates = yystack.yytops.yystates;
if (yystates)
@@ -2169,9 +2175,9 @@ b4_syncline([@oline@], [@ofile@])])dnl
yystack.yynextFree -= 1;
yystack.yyspaceLeft += 1;
}
yyfreeGLRStack (&yystack);
}
yyfreeGLRStack (&yystack);
return yyresult;
}