From eddfa12569910a22ba8343693d17e19c74c05538 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 14 Jan 2009 10:26:58 -0800 Subject: [PATCH] Cleanup the lexor state information when done parsing. This patch frees the lexor buffers when we are done parsing the input file. --- vvp/lexor.lex | 15 +++++++++++++++ vvp/main.cc | 5 +++-- vvp/parse_misc.h | 4 +++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/vvp/lexor.lex b/vvp/lexor.lex index d70c00754..42f3c3a58 100644 --- a/vvp/lexor.lex +++ b/vvp/lexor.lex @@ -264,3 +264,18 @@ int yywrap() { return -1; } + +/* + * 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/vvp/main.cc b/vvp/main.cc index a729d7bc9..e9dac4ba1 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -342,8 +342,9 @@ int main(int argc, char*argv[]) for (unsigned idx = 0 ; idx < module_cnt ; idx += 1) vpip_load_module(module_tab[idx]); - if (int rc = compile_design(design_path)) - return rc; + int ret_cd = compile_design(design_path); + destroy_lexor(); + if (ret_cd) return ret_cd; if (!have_ivl_version) { if (verbose_flag) vpi_mcd_printf(1, "... "); diff --git a/vvp/parse_misc.h b/vvp/parse_misc.h index 859ff8787..0e130f662 100644 --- a/vvp/parse_misc.h +++ b/vvp/parse_misc.h @@ -1,7 +1,7 @@ #ifndef __parse_misc_H #define __parse_misc_H /* - * Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -39,6 +39,8 @@ extern void verify_version(char *ivl_ver, char* commit); extern int yylex(void); extern void yyerror(const char*msg); +extern void destroy_lexor(); + /* * This is the path of the current source file. */