This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
[patch] more robust free_current_contents + mi cleanup cleanup
- To: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: [patch] more robust free_current_contents + mi cleanup cleanup
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Tue, 16 May 2000 14:58:12 +1000
- Organization: Cygnus Solutions
FYI,
Andrew
Index: ChangeLog
Tue May 16 14:17:20 2000 Andrew Cagney <cagney@b1.cygnus.com>
* utils.c (free_current_contents): Make more robust.
Index: mi/ChangeLog-mi
Tue May 16 14:13:41 2000 Andrew Cagney <cagney@b1.cygnus.com>
* mi-main.c (mi_cmd_execute): Use free_current_contents.
(free_and_reset): Delete.
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.10
diff -p -r1.10 utils.c
*** utils.c 2000/05/16 02:43:39 1.10
--- utils.c 2000/05/16 04:54:29
*************** void
*** 390,397 ****
free_current_contents (void *ptr)
{
void **location = ptr;
if (*location != NULL)
! free (*location);
}
/* Provide a known function that does nothing, to use as a base for
--- 390,402 ----
free_current_contents (void *ptr)
{
void **location = ptr;
+ if (location == NULL)
+ internal_error ("free_current_contents: NULL pointer");
if (*location != NULL)
! {
! free (*location);
! *location = NULL;
! }
}
/* Provide a known function that does nothing, to use as a base for
Index: mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.4
diff -p -r1.4 mi-main.c
*** mi-main.c 2000/05/15 11:48:50 1.4
--- mi-main.c 2000/05/16 04:54:36
*************** static enum mi_cmd_result mi_execute_asy
*** 70,76 ****
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);
--- 70,75 ----
*************** mi_cmd_execute (struct mi_parse *parse)
*** 1199,1205 ****
}
}
last_async_command = xstrdup (parse->token);
! make_exec_cleanup ((make_cleanup_func) free_and_reset, &last_async_command);
/* FIXME: DELETE THIS! */
if (parse->cmd->args_func != NULL)
return parse->cmd->args_func (parse->args, 0 /*from_tty */ );
--- 1198,1204 ----
}
}
last_async_command = xstrdup (parse->token);
! 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 */ );
*************** mi_cmd_execute (struct mi_parse *parse)
*** 1224,1236 ****
fputs_unfiltered ("\"\n", raw_stdout);
return MI_CMD_ERROR;
}
- }
-
- void
- free_and_reset (char **arg)
- {
- free (*arg);
- *arg = NULL;
}
static void
--- 1223,1228 ----