Mercurial > octave-nkf
diff src/ov-usr-fcn.cc @ 3239:d54ef0aa6e82
[project @ 1999-03-27 17:40:45 by jwe]
author | jwe |
---|---|
date | Sat, 27 Mar 1999 17:40:46 +0000 |
parents | 30770ba4457a |
children | 4d33b1e56bff |
line wrap: on
line diff
--- a/src/ov-usr-fcn.cc Fri Mar 26 17:48:35 1999 +0000 +++ b/src/ov-usr-fcn.cc Sat Mar 27 17:40:46 1999 +0000 @@ -226,6 +226,24 @@ } static void +clear_param_list (void *lst) +{ + tree_parameter_list *tmp = static_cast<tree_parameter_list *> (lst); + + if (tmp) + tmp->clear (); +} + +static void +clear_args_passed (void *fcn) +{ + octave_user_function *tmp = static_cast<octave_user_function *> (fcn); + + if (tmp) + tmp->clear_args_passed (); +} + +static void unprotect_function (void *sr_arg) { symbol_record *sr = static_cast<symbol_record *> (sr_arg); @@ -302,6 +320,12 @@ args_passed = args; + // Force cache of arguments to be undefined when this function exits. + // Doing so decrements the reference counts on the values of local + // variables that are also named function parameters. + + unwind_protect::add (::clear_args_passed, this); + string_vector arg_names = args.name_tags (); unwind_protect_int (num_args_passed); @@ -317,6 +341,12 @@ goto abort; } + // Force parameter list to be undefined when this function exits. + // Doing so decrements the reference counts on the values of local + // variables that are also named function parameters. + + unwind_protect::add (clear_param_list, param_list); + if (ret_list && Vdefine_all_return_values) { octave_value tmp = builtin_any_variable ("default_return_value"); @@ -325,6 +355,12 @@ ret_list->initialize_undefined_elements (tmp); } + // Force return list to be undefined when this function exits. + // Doing so decrements the reference counts on the values of local + // variables that are also named values returned by this function. + + unwind_protect::add (clear_param_list, ret_list); + // The following code is in a separate scope to avoid warnings from // G++ about `goto abort' crossing the initialization of some // variables.