# HG changeset patch # User jwe # Date 1150174771 0 # Node ID 92d2be71e7cc0cb292e8c67d467479775eb6e8b9 # Parent 68f8017ef07717f137e10d588d2abb5b15af0de3 [project @ 2006-06-13 04:59:30 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2006-06-13 John W. Eaton + + * pt-stmt.cc (tree_statement_list::eval): + Clear retval before each statement is evaluated. + 2006-06-12 John W. Eaton * unwind-prot.h (unwind_protect_fptr): New macro. diff --git a/src/pt-stmt.cc b/src/pt-stmt.cc --- a/src/pt-stmt.cc +++ b/src/pt-stmt.cc @@ -165,6 +165,17 @@ { OCTAVE_QUIT; + // Clear preivous values before next statement is evaluated + // so that we aren't holding an extra reference to a value + // that may be used next. For example, in code like this: + // + // X = rand (N); ## refcount should be 1 after this statement. + // X(idx) = val; ## no extra copy should be needed, but + // ## we will be faked out if retval is not + // ## cleared between statements here. + + retval = octave_value_list (); + retval = elt->eval (silent, nargout, function_body); if (error_state) @@ -179,8 +190,6 @@ } else error ("invalid statement found in statement list!"); - - } return retval;