mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-31 14:10:09 +01:00
Make the lexer reentrant (to avoid "still reachable" memory).
This allows the final program to be 100% "valgrind clean", (freeing all memory that it allocates). This will make it much easier to ensure that any allocation that parser actions perform are also cleaned up.
This commit is contained in:
parent
3a37b8701c
commit
38aa83560b
3 changed files with 14 additions and 4 deletions
|
|
@ -28,7 +28,7 @@
|
|||
#include "glcpp-parse.h"
|
||||
%}
|
||||
|
||||
%option noyywrap
|
||||
%option reentrant noyywrap
|
||||
|
||||
%%
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,13 @@
|
|||
#define YYSTYPE int
|
||||
|
||||
void
|
||||
yyerror (const char *error);
|
||||
yyerror (const char *error, void *scanner);
|
||||
|
||||
%}
|
||||
|
||||
%parse-param {void *scanner}
|
||||
%lex-param {void *scanner}
|
||||
|
||||
%token TOKEN
|
||||
|
||||
%%
|
||||
|
|
@ -51,7 +54,7 @@ token: TOKEN
|
|||
%%
|
||||
|
||||
void
|
||||
yyerror (const char *error)
|
||||
yyerror (const char *error, void *scanner)
|
||||
{
|
||||
fprintf (stderr, "Parse error: %s\n", error);
|
||||
}
|
||||
|
|
|
|||
9
glcpp.c
9
glcpp.c
|
|
@ -24,5 +24,12 @@
|
|||
int
|
||||
main (void)
|
||||
{
|
||||
return yyparse ();
|
||||
int ret;
|
||||
void *scanner;
|
||||
|
||||
yylex_init (&scanner);
|
||||
ret = yyparse (scanner);
|
||||
yylex_destroy (scanner);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue