Use scoped_value_mark in more places

I looked at all the spots using value_mark, and converted all the
straightforward ones to use scoped_value_mark instead.

Regression tested on x86-64 Fedora 34.
This commit is contained in:
Tom Tromey
2022-10-03 13:51:58 -06:00
parent ce6c3d253b
commit 65558ca5df
8 changed files with 36 additions and 53 deletions

View File

@@ -512,8 +512,6 @@ static enum command_control_type
execute_control_command_1 (struct command_line *cmd, int from_tty)
{
struct command_line *current;
struct value *val;
struct value *val_mark;
int loop;
enum command_control_type ret;
@@ -567,10 +565,11 @@ execute_control_command_1 (struct command_line *cmd, int from_tty)
QUIT;
/* Evaluate the expression. */
val_mark = value_mark ();
val = evaluate_expression (expr.get ());
cond_result = value_true (val);
value_free_to_mark (val_mark);
{
scoped_value_mark mark;
value *val = evaluate_expression (expr.get ());
cond_result = value_true (val);
}
/* If the value is false, then break out of the loop. */
if (!cond_result)
@@ -621,16 +620,17 @@ execute_control_command_1 (struct command_line *cmd, int from_tty)
ret = simple_control;
/* Evaluate the conditional. */
val_mark = value_mark ();
val = evaluate_expression (expr.get ());
{
scoped_value_mark mark;
value *val = evaluate_expression (expr.get ());
/* Choose which arm to take commands from based on the value
of the conditional expression. */
if (value_true (val))
current = cmd->body_list_0.get ();
else if (cmd->body_list_1 != nullptr)
current = cmd->body_list_1.get ();
value_free_to_mark (val_mark);
/* Choose which arm to take commands from based on the value
of the conditional expression. */
if (value_true (val))
current = cmd->body_list_0.get ();
else if (cmd->body_list_1 != nullptr)
current = cmd->body_list_1.get ();
}
/* Execute commands in the given arm. */
while (current)