# HG changeset patch # User John W. Eaton # Date 1322815897 18000 # Node ID 2c664266e9d0f590e9973a29e035ad9504ad2977 # Parent 09432c6f23e7d1accea4ada849e54085b2fc0a05 clean up parser memory on exit * lex.h, lex.ll (clear_all_buffers, cleanup_parser): New functions. * toplev.cc (clean_up_and_exit): Call cleanup_parser here. diff --git a/src/lex.h b/src/lex.h --- a/src/lex.h +++ b/src/lex.h @@ -43,6 +43,10 @@ // Delete a buffer. extern OCTINTERP_API void delete_buffer (YY_BUFFER_STATE buf); +extern OCTINTERP_API void clear_all_buffers (void); + +extern OCTINTERP_API void cleanup_parser (void); + // Is the given string a keyword? extern bool is_keyword (const std::string& s); diff --git a/src/lex.ll b/src/lex.ll --- a/src/lex.ll +++ b/src/lex.ll @@ -1416,6 +1416,22 @@ yy_delete_buffer (buf); } +// Delete all buffers from the stack. +void +clear_all_buffers (void) +{ + while (current_buffer ()) + octave_pop_buffer_state (); +} + +void +cleanup_parser (void) +{ + reset_parser (); + + clear_all_buffers (); +} + // Restore a buffer (for unwind-prot). void diff --git a/src/toplev.cc b/src/toplev.cc --- a/src/toplev.cc +++ b/src/toplev.cc @@ -676,6 +676,8 @@ // Clean up symbol table. SAFE_CALL (symbol_table::cleanup, ()); + SAFE_CALL (cleanup_parser, ()); + SAFE_CALL (sysdep_cleanup, ()) if (octave_exit)