aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-cmds.c2
-rw-r--r--gdb/cli/cli-decode.c3
-rw-r--r--gdb/cli/cli-script.c27
-rw-r--r--gdb/cli/cli-setshow.c4
4 files changed, 13 insertions, 23 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index bcd7802..aa9a9a5 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -636,7 +636,7 @@ source_command (char *args, int from_tty)
{
struct cleanup *old_cleanups;
char *file = args;
- int *old_source_verbose = xmalloc (sizeof(int));
+ int *old_source_verbose = XNEW (int);
int search_path = 0;
*old_source_verbose = source_verbose;
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index e406157..f5b6fc4 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -192,8 +192,7 @@ struct cmd_list_element *
add_cmd (const char *name, enum command_class theclass, cmd_cfunc_ftype *fun,
const char *doc, struct cmd_list_element **list)
{
- struct cmd_list_element *c
- = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
+ struct cmd_list_element *c = XNEW (struct cmd_list_element);
struct cmd_list_element *p, *iter;
/* Turn each alias of the old command into an alias of the new
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 4bd18a7..1717240 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -109,15 +109,12 @@ build_command_line (enum command_control_type type, char *args)
error (_("if/while commands require arguments."));
gdb_assert (args != NULL);
- cmd = (struct command_line *) xmalloc (sizeof (struct command_line));
+ cmd = XNEW (struct command_line);
cmd->next = NULL;
cmd->control_type = type;
cmd->body_count = 1;
- cmd->body_list
- = (struct command_line **) xmalloc (sizeof (struct command_line *)
- * cmd->body_count);
- memset (cmd->body_list, 0, sizeof (struct command_line *) * cmd->body_count);
+ cmd->body_list = XCNEWVEC (struct command_line *, cmd->body_count);
cmd->line = xstrdup (args);
return cmd;
@@ -722,7 +719,7 @@ setup_user_args (char *p)
struct cleanup *old_chain;
unsigned int arg_count = 0;
- args = (struct user_args *) xmalloc (sizeof (struct user_args));
+ args = XNEW (struct user_args);
memset (args, 0, sizeof (struct user_args));
args->next = user_args;
@@ -918,11 +915,9 @@ realloc_body_list (struct command_line *command, int new_length)
if (new_length <= n)
return;
- body_list = (struct command_line **)
- xmalloc (sizeof (struct command_line *) * new_length);
+ body_list = XCNEWVEC (struct command_line *, new_length);
memcpy (body_list, command->body_list, sizeof (struct command_line *) * n);
- memset (body_list + n, 0, sizeof (struct command_line *) * (new_length - n));
xfree (command->body_list);
command->body_list = body_list;
@@ -1076,8 +1071,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
}
else if (p_end - p == 10 && startswith (p, "loop_break"))
{
- *command = (struct command_line *)
- xmalloc (sizeof (struct command_line));
+ *command = XNEW (struct command_line);
(*command)->next = NULL;
(*command)->line = NULL;
(*command)->control_type = break_control;
@@ -1086,8 +1080,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
}
else if (p_end - p == 13 && startswith (p, "loop_continue"))
{
- *command = (struct command_line *)
- xmalloc (sizeof (struct command_line));
+ *command = XNEW (struct command_line);
(*command)->next = NULL;
(*command)->line = NULL;
(*command)->control_type = continue_control;
@@ -1101,8 +1094,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
if (!parse_commands || not_handled)
{
/* A normal command. */
- *command = (struct command_line *)
- xmalloc (sizeof (struct command_line));
+ *command = XNEW (struct command_line);
(*command)->next = NULL;
(*command)->line = savestring (p, p_end - p);
(*command)->control_type = simple_control;
@@ -1414,7 +1406,7 @@ copy_command_lines (struct command_line *cmds)
if (cmds)
{
- result = (struct command_line *) xmalloc (sizeof (struct command_line));
+ result = XNEW (struct command_line);
result->next = copy_command_lines (cmds->next);
result->line = xstrdup (cmds->line);
@@ -1424,8 +1416,7 @@ copy_command_lines (struct command_line *cmds)
{
int i;
- result->body_list = (struct command_line **)
- xmalloc (sizeof (struct command_line *) * cmds->body_count);
+ result->body_list = XNEWVEC (struct command_line *, cmds->body_count);
for (i = 0; i < cmds->body_count; i++)
result->body_list[i] = copy_command_lines (cmds->body_list[i]);
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 8d01b52..ca41d8e 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -475,8 +475,8 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
p = p->prefix;
}
- cp = name = xmalloc (length);
- cmds = xmalloc (sizeof (struct cmd_list_element *) * i);
+ cp = name = (char *) xmalloc (length);
+ cmds = XNEWVEC (struct cmd_list_element *, i);
/* Track back through filed 'prefix' and cache them in CMDS. */
for (i = 0, p = c; p != NULL; i++)