diff --git a/ivlpp/globals.h b/ivlpp/globals.h index 3c2b95865..623baa54a 100644 --- a/ivlpp/globals.h +++ b/ivlpp/globals.h @@ -22,6 +22,7 @@ # include extern void reset_lexor(FILE*out, char*paths[]); +extern void destroy_lexor(); extern void load_precompiled_defines(FILE*src); extern void define_macro(const char*name, const char*value, int keyword, int argc); diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 6e780f69d..d0a086e2e 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -1803,3 +1803,17 @@ void reset_lexor(FILE* out, char* paths[]) tail = isp; } } + +/* + * Modern version of flex (>=2.5.9) can clean up the scanner data. + */ +void destroy_lexor() +{ +# ifdef FLEX_SCANNER +# if YY_FLEX_MAJOR_VERSION >= 2 && YY_FLEX_MINOR_VERSION >= 5 +# if defined(YY_FLEX_SUBMINOR_VERSION) && YY_FLEX_SUBMINOR_VERSION >= 9 + yylex_destroy(); +# endif +# endif +# endif +} diff --git a/ivlpp/main.c b/ivlpp/main.c index af7e66719..a8d761ebc 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -370,6 +370,7 @@ int main(int argc, char*argv[]) start scanning. */ reset_lexor(out, source_list); if (yylex()) return -1; + destroy_lexor(); if(depend_file) { fclose(depend_file);