Mercurial > hg > octave-lyh
changeset 9981:692ab4eaf965
clean up top-level variables when exiting Octave
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 14 Dec 2009 12:11:53 +0100 |
parents | e352f8366b02 |
children | 7cef030b8069 |
files | src/ChangeLog src/symtab.cc src/symtab.h src/toplev.cc |
diffstat | 4 files changed, 44 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2009-12-14 Jaroslav Hajek <highegg@gmail.com> + + * symtab.cc (symbol_table::cleanup): New static method. + * symtab.h: Declare it. + * toplev.cc (clean_up_and_exit): Call it here. + 2009-12-12 Shai Ayal <shaiay@users.sourceforge.net> * DLD-FUNCTIONS/fltk_backend.cc (plot_window::toggle_grid,
--- a/src/symtab.cc +++ b/src/symtab.cc @@ -1331,6 +1331,39 @@ } } +void symbol_table::cleanup (void) +{ + // Clear variables in top scope. + all_instances[xtop_scope]->clear_all (); + + // Clear function table. This is a hard clear, ignoring mlocked functions. + fcn_table.clear (); + + // Clear variables in global scope. + // FIXME: are there any? + all_instances[xglobal_scope]->clear_all (); + + // Clear global variables. + global_table.clear (); + + // Delete all possibly remaining scopes. + for (all_instances_iterator iter = all_instances.begin (); + iter != all_instances.end (); iter++) + { + scope_id scope = iter->first; + if (scope != xglobal_scope && scope != xtop_scope) + scope_id_cache::free (scope); + + // First zero the table entry to avoid possible duplicate delete. + symbol_table *inst = iter->second; + iter->second = 0; + + // Now delete the scope. Note that there may be side effects, such as + // deleting other scopes. + delete inst; + } +} + DEFUN (ignore_function_time_stamp, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {@var{val} =} ignore_function_time_stamp ()\n\