diff options
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | flex.skl | 21 | ||||
-rw-r--r-- | tests/test-c++-multiple-scanners/main.cpp | 2 | ||||
-rw-r--r-- | tests/test-c-cpp-nr/scanner.l | 1 |
4 files changed, 20 insertions, 9 deletions
@@ -5,7 +5,10 @@ See the file COPYING for copying conditions. * after version 2.5.33 -* added new unit test for c++ and yywrap +** memory leaks removed from the C++ scanner (but the C++ scanner is +still experimental and may change radically without notice) + +** added new unit test for c++ and yywrap ** portability fixes to some unit tests @@ -1462,13 +1462,6 @@ m4_ifdef( [[M4_YY_USES_REJECT]], ]]) } -yyFlexLexer::~yyFlexLexer() -{ - delete [] yy_state_buf; - yyfree( yy_start_stack M4_YY_CALL_LAST_ARG ); - yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG); -} - void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) { if ( new_in ) @@ -2781,9 +2774,14 @@ m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]], %endif -%if-c-only SNIP! this currently causes conflicts with the c++ scanner +%if-c-or-c++ +%if-c-only /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy YYFARGS0(void) +%endif +%if-c++-only +yyFlexLexer::~yyFlexLexer() +%endif { M4_YY_DECL_GUTS_VAR(); @@ -2798,6 +2796,12 @@ int yylex_destroy YYFARGS0(void) yyfree(YY_G(yy_buffer_stack) M4_YY_CALL_LAST_ARG); YY_G(yy_buffer_stack) = NULL; +%if-c++-only + delete [] YY_G(yy_state_buf); + yyfree(YY_G(yy_start_stack) M4_YY_CALL_LAST_ARG ); +%endif + +%if-c-only m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]], [[ /* Destroy the start condition stack. */ @@ -2821,6 +2825,7 @@ m4_ifdef( [[M4_YY_USES_REJECT]], yyscanner = NULL; %endif return 0; +%endif } %endif diff --git a/tests/test-c++-multiple-scanners/main.cpp b/tests/test-c++-multiple-scanners/main.cpp index aa89949..08fe2c1 100644 --- a/tests/test-c++-multiple-scanners/main.cpp +++ b/tests/test-c++-multiple-scanners/main.cpp @@ -47,6 +47,8 @@ main ( int argc, char** argv ) S2_ok = S2->yylex(); } printf("TEST RETURNING OK.\n"); + delete S1; + delete S2; return 0; } diff --git a/tests/test-c-cpp-nr/scanner.l b/tests/test-c-cpp-nr/scanner.l index 63543e4..e184008 100644 --- a/tests/test-c-cpp-nr/scanner.l +++ b/tests/test-c-cpp-nr/scanner.l @@ -51,6 +51,7 @@ main () yyin = stdin; yyout = stdout; yylex(); + yylex_destroy(); printf("TEST RETURNING OK.\n"); return 0; } |