Mercurial > hg > octave-nkf
changeset 13973:2c664266e9d0
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.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 02 Dec 2011 03:51:37 -0500 |
parents | 09432c6f23e7 |
children | f5bd61eb032f |
files | src/lex.h src/lex.ll src/toplev.cc |
diffstat | 3 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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