Mercurial > hg > octave-lyh
comparison src/input.cc @ 13970:c93b953f7d54
plug some memory leaks
* oct-parse.yy, parse.h (cleanup_statement_list): New function.
* toplev.cc (main_loop): Put cleanup_statement_list on the
unwind_protect stack to delete the command list created by the
parser instead of deleting it directly.
* oct-parse.yy (parse_fcn_file, eval_string): Likewise.
* input.cc (get_debug_input): Likewise.
* pt-loop.cc (tree_simple_for_command::~tree_simple_for_command,
tree_complex_for_command::~tree_complex_for_command):
Also delete lhs expression.
* pt-idx.cc (tree_index_expression::~tree_index_expression):
Also delete contents of dyn_field list.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 01 Dec 2011 04:26:46 -0500 |
parents | 79aa00a94e9e |
children | 72c96de7a403 |
comparison
equal
deleted
inserted
replaced
13969:3b5afcec526b | 13970:c93b953f7d54 |
---|---|
747 // This is the same as yyparse in parse.y. | 747 // This is the same as yyparse in parse.y. |
748 int retval = octave_parse (); | 748 int retval = octave_parse (); |
749 | 749 |
750 if (retval == 0 && global_command) | 750 if (retval == 0 && global_command) |
751 { | 751 { |
752 unwind_protect inner_frame; | |
753 | |
754 // Use an unwind-protect cleanup function so that the | |
755 // global_command list will be deleted in the event of an | |
756 // interrupt. | |
757 | |
758 inner_frame.add_fcn (cleanup_statement_list, &global_command); | |
759 | |
752 global_command->accept (*current_evaluator); | 760 global_command->accept (*current_evaluator); |
753 | |
754 // FIXME -- To avoid a memory leak, global_command should be | |
755 // deleted, I think. But doing that here causes trouble if | |
756 // an error occurs while executing a debugging command | |
757 // (dbstep, for example). It's not clear to me why that | |
758 // happens. | |
759 // | |
760 // delete global_command; | |
761 // | |
762 // global_command = 0; | |
763 | 761 |
764 if (octave_completion_matches_called) | 762 if (octave_completion_matches_called) |
765 octave_completion_matches_called = false; | 763 octave_completion_matches_called = false; |
766 } | 764 } |
767 | 765 |