mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
(YYFREE, YYMALLOC, YYREALLOC): New macros.
All uses of free, malloc, realloc changed to use these macros, and unnecessary casts removed.
This commit is contained in:
30
data/glr.c
30
data/glr.c
@@ -219,6 +219,16 @@ static YYLTYPE yyloc_default;
|
|||||||
]/* Line __line__ of glr.c. */
|
]/* Line __line__ of glr.c. */
|
||||||
b4_syncline([@oline@], [@ofile@])
|
b4_syncline([@oline@], [@ofile@])
|
||||||
[
|
[
|
||||||
|
#ifndef YYFREE
|
||||||
|
# define YYFREE free
|
||||||
|
#endif
|
||||||
|
#ifndef YYMALLOC
|
||||||
|
# define YYMALLOC malloc
|
||||||
|
#endif
|
||||||
|
#ifndef YYREALLOC
|
||||||
|
# define YYREALLOC realloc
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
typedef bool yybool;
|
typedef bool yybool;
|
||||||
#else
|
#else
|
||||||
@@ -865,13 +875,13 @@ yyinitStateSet (yyGLRStateSet* yyset)
|
|||||||
{
|
{
|
||||||
yyset->yysize = 1;
|
yyset->yysize = 1;
|
||||||
yyset->yycapacity = 16;
|
yyset->yycapacity = 16;
|
||||||
yyset->yystates = (yyGLRState**) malloc (16 * sizeof (yyset->yystates[0]));
|
yyset->yystates = YYMALLOC (16 * sizeof yyset->yystates[0]);
|
||||||
yyset->yystates[0] = NULL;
|
yyset->yystates[0] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void yyfreeStateSet (yyGLRStateSet* yyset)
|
static void yyfreeStateSet (yyGLRStateSet* yyset)
|
||||||
{
|
{
|
||||||
free (yyset->yystates);
|
YYFREE (yyset->yystates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize STACK to a single empty stack, with total maximum
|
/** Initialize STACK to a single empty stack, with total maximum
|
||||||
@@ -884,7 +894,7 @@ yyinitGLRStack (yyGLRStack* yystack, size_t yysize)
|
|||||||
yynerrs = 0;
|
yynerrs = 0;
|
||||||
yystack->yyspaceLeft = yysize;
|
yystack->yyspaceLeft = yysize;
|
||||||
yystack->yynextFree = yystack->yyitems =
|
yystack->yynextFree = yystack->yyitems =
|
||||||
(yyGLRStackItem*) malloc (yysize * sizeof (yystack->yynextFree[0]));
|
YYMALLOC (yysize * sizeof yystack->yynextFree[0]);
|
||||||
yystack->yysplitPoint = NULL;
|
yystack->yysplitPoint = NULL;
|
||||||
yystack->yylastDeleted = NULL;
|
yystack->yylastDeleted = NULL;
|
||||||
yyinitStateSet (&yystack->yytops);
|
yyinitStateSet (&yystack->yytops);
|
||||||
@@ -948,7 +958,7 @@ yyexpandGLRStack (yyGLRStack* yystack]b4_pure_formals[)
|
|||||||
yystack->yytops.yystates[yyn] =
|
yystack->yytops.yystates[yyn] =
|
||||||
YYRELOC (yystack->yyitems, yynewStack.yyitems,
|
YYRELOC (yystack->yyitems, yynewStack.yyitems,
|
||||||
yystack->yytops.yystates[yyn], yystate);
|
yystack->yytops.yystates[yyn], yystate);
|
||||||
free (yystack->yyitems);
|
YYFREE (yystack->yyitems);
|
||||||
yystack->yyitems = yynewStack.yyitems;
|
yystack->yyitems = yynewStack.yyitems;
|
||||||
yystack->yynextFree = yynewStack.yynextFree + yysize;
|
yystack->yynextFree = yynewStack.yynextFree + yysize;
|
||||||
yystack->yyspaceLeft = yynewStack.yyspaceLeft - yysize;
|
yystack->yyspaceLeft = yynewStack.yyspaceLeft - yysize;
|
||||||
@@ -962,7 +972,7 @@ yyexpandGLRStack (yyGLRStack* yystack]b4_pure_formals[)
|
|||||||
static void
|
static void
|
||||||
yyfreeGLRStack (yyGLRStack* yystack)
|
yyfreeGLRStack (yyGLRStack* yystack)
|
||||||
{
|
{
|
||||||
free (yystack->yyitems);
|
YYFREE (yystack->yyitems);
|
||||||
yyfreeStateSet (&yystack->yytops);
|
yyfreeStateSet (&yystack->yytops);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1231,9 +1241,9 @@ yysplitStack (yyGLRStack* yystack, int yyk)
|
|||||||
{
|
{
|
||||||
yystack->yytops.yycapacity *= 2;
|
yystack->yytops.yycapacity *= 2;
|
||||||
yystack->yytops.yystates =
|
yystack->yytops.yystates =
|
||||||
(yyGLRState**) realloc (yystack->yytops.yystates,
|
YYREALLOC (yystack->yytops.yystates,
|
||||||
yystack->yytops.yycapacity
|
(yystack->yytops.yycapacity
|
||||||
* sizeof (yyGLRState*));
|
* sizeof yystack->yytops.yystates[0]));
|
||||||
}
|
}
|
||||||
yystack->yytops.yystates[yystack->yytops.yysize]
|
yystack->yytops.yystates[yystack->yytops.yysize]
|
||||||
= yystack->yytops.yystates[yyk];
|
= yystack->yytops.yystates[yyk];
|
||||||
@@ -1644,7 +1654,7 @@ yyreportSyntaxError (yyGLRStack* yystack,
|
|||||||
}
|
}
|
||||||
yysize += (sizeof ("syntax error, unexpected ")
|
yysize += (sizeof ("syntax error, unexpected ")
|
||||||
+ strlen (yytokenName (*yytokenp)));
|
+ strlen (yytokenName (*yytokenp)));
|
||||||
yymsg = (char*) malloc (yysize);
|
yymsg = YYMALLOC (yysize);
|
||||||
if (yymsg != 0)
|
if (yymsg != 0)
|
||||||
{
|
{
|
||||||
char* yyp = yymsg;
|
char* yyp = yymsg;
|
||||||
@@ -1663,7 +1673,7 @@ yyreportSyntaxError (yyGLRStack* yystack,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
yyerror (]b4_lyyerror_args[yymsg);
|
yyerror (]b4_lyyerror_args[yymsg);
|
||||||
free (yymsg);
|
YYFREE (yymsg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
yyerror (]b4_lyyerror_args["syntax error; also virtual memory exhausted");
|
yyerror (]b4_lyyerror_args["syntax error; also virtual memory exhausted");
|
||||||
|
|||||||
Reference in New Issue
Block a user