From 1e06a2ddef15a8377b8b46d6d20b4e5dbf718030 Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 4 Nov 2008 14:47:32 -0800 Subject: [PATCH] ivlpp - clear lexor dynamic state information for flex >= 2.5.9 For flex version 2.5.9 and later there is a function "yylex_destroy()" that clears any space dynamically allocated by the scanner. --- ivlpp/globals.h | 1 + ivlpp/lexor.lex | 14 ++++++++++++++ ivlpp/main.c | 1 + 3 files changed, 16 insertions(+) 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);