From e2f9c4749114f7ddcd18e62e5559d0fa14bf0935 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Tue, 16 May 2000 04:57:49 +0000 Subject: [PATCH] Make free_current_contents more robust. Use in MI. --- gdb/ChangeLog | 4 ++++ gdb/mi/ChangeLog-mi | 5 +++++ gdb/mi/mi-main.c | 10 +--------- gdb/utils.c | 7 ++++++- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index aa37cd5386d..ff3747ed75a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +Tue May 16 14:17:20 2000 Andrew Cagney + + * utils.c (free_current_contents): Make more robust. + Tue May 16 13:30:08 2000 Andrew Cagney * symtab.h (make_cleanup_discard_minimal_symbols): Replace diff --git a/gdb/mi/ChangeLog-mi b/gdb/mi/ChangeLog-mi index d2eafae4f3d..5edfce47222 100644 --- a/gdb/mi/ChangeLog-mi +++ b/gdb/mi/ChangeLog-mi @@ -1,3 +1,8 @@ +Tue May 16 14:13:41 2000 Andrew Cagney + + * mi-main.c (mi_cmd_execute): Use free_current_contents. + (free_and_reset): Delete. + Mon May 15 16:17:56 2000 Andrew Cagney * mi-main.c (mi_cmd_data_assign, mi_cmd_data_evaluate_expression), diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 22745a07691..872b7b20f2b 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -70,7 +70,6 @@ static enum mi_cmd_result mi_execute_async_cli_command (char *mi, char *args, in static void mi_execute_command_wrapper (char *cmd); void mi_exec_async_cli_cmd_continuation (struct continuation_arg *arg); -static void free_and_reset (char **arg); static int register_changed_p (int regnum); static int get_register (int regnum, int format); @@ -1199,7 +1198,7 @@ mi_cmd_execute (struct mi_parse *parse) } } last_async_command = xstrdup (parse->token); - make_exec_cleanup ((make_cleanup_func) free_and_reset, &last_async_command); + make_exec_cleanup (free_current_contents, &last_async_command); /* FIXME: DELETE THIS! */ if (parse->cmd->args_func != NULL) return parse->cmd->args_func (parse->args, 0 /*from_tty */ ); @@ -1226,13 +1225,6 @@ mi_cmd_execute (struct mi_parse *parse) } } -void -free_and_reset (char **arg) -{ - free (*arg); - *arg = NULL; -} - static void mi_execute_command_wrapper (char *cmd) { diff --git a/gdb/utils.c b/gdb/utils.c index 3fd055caad9..45fdb1dd47b 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -390,8 +390,13 @@ void free_current_contents (void *ptr) { void **location = ptr; + if (location == NULL) + internal_error ("free_current_contents: NULL pointer"); if (*location != NULL) - free (*location); + { + free (*location); + *location = NULL; + } } /* Provide a known function that does nothing, to use as a base for -- 2.30.2