Replace the savestring calls by xstrdup calls where possible.
	* breakpoint.c (condition_command, set_raw_breakpoint)
	(create_catchpoint, update_breakpoint_locations): Replace the
	savestring calls by xstrdup calls where possible.
	* buildsym.c (start_subfile, patch_subfile_names, record_debugformat)
	(record_producer): Likewise.
	* coffread.c (coff_start_symtab, complete_symtab): Likewise.
	* corefile.c (set_gnutarget): Likewise.
	* dbxread.c (add_new_header_file): Likewise.
	* demangle.c (set_demangling_command, set_demangling_style): Likewise.
	* event-top.c (push_prompt, pop_prompt, command_line_handler)
	(set_async_prompt): Likewise.
	* infcmd.c (set_inferior_io_terminal, attach_command_post_wait):
	Likewise.
	* language.c (set_language_command, _initialize_language): Likewise.
	* linespec.c (decode_line_2): Likewise.
	* rs6000-nat.c (add_vmap): Likewise.
	* top.c (set_prompt, init_history, init_main): Likewise.
	* tracepoint.c (stringify_collection_list): Likewise.
	* varobj.c (varobj_create): Remove variable expr_len.  Replace the
	savestring calls by xstrdup calls where possible.
	(value_of_root, c_name_of_variable, c_describe_child): Replace the
	savestring calls by xstrdup calls where possible.
	* xcoffread.c (complete_symtab): Likewise.
	* cli/cli-script.c (build_command_line, define_command): Likewise.
	* cli/cli-setshow.c (do_setshow_command): Likewise.
This commit is contained in:
Jan Kratochvil 2009-05-23 16:17:18 +00:00
parent 61d8f2758f
commit 1b36a34b7a
18 changed files with 83 additions and 69 deletions

View file

@ -1,3 +1,32 @@
2009-05-23 Jan Kratochvil <jan.kratochvil@redhat.com>
Replace the savestring calls by xstrdup calls where possible.
* breakpoint.c (condition_command, set_raw_breakpoint)
(create_catchpoint, update_breakpoint_locations): Replace the
savestring calls by xstrdup calls where possible.
* buildsym.c (start_subfile, patch_subfile_names, record_debugformat)
(record_producer): Likewise.
* coffread.c (coff_start_symtab, complete_symtab): Likewise.
* corefile.c (set_gnutarget): Likewise.
* dbxread.c (add_new_header_file): Likewise.
* demangle.c (set_demangling_command, set_demangling_style): Likewise.
* event-top.c (push_prompt, pop_prompt, command_line_handler)
(set_async_prompt): Likewise.
* infcmd.c (set_inferior_io_terminal, attach_command_post_wait):
Likewise.
* language.c (set_language_command, _initialize_language): Likewise.
* linespec.c (decode_line_2): Likewise.
* rs6000-nat.c (add_vmap): Likewise.
* top.c (set_prompt, init_history, init_main): Likewise.
* tracepoint.c (stringify_collection_list): Likewise.
* varobj.c (varobj_create): Remove variable expr_len. Replace the
savestring calls by xstrdup calls where possible.
(value_of_root, c_name_of_variable, c_describe_child): Replace the
savestring calls by xstrdup calls where possible.
* xcoffread.c (complete_symtab): Likewise.
* cli/cli-script.c (build_command_line, define_command): Likewise.
* cli/cli-setshow.c (do_setshow_command): Likewise.
2009-05-23 Jan Kratochvil <jan.kratochvil@redhat.com> 2009-05-23 Jan Kratochvil <jan.kratochvil@redhat.com>
Remove already unreachable code. Remove already unreachable code.

View file

@ -597,7 +597,7 @@ condition_command (char *arg, int from_tty)
arg = p; arg = p;
/* I don't know if it matters whether this is the string the user /* I don't know if it matters whether this is the string the user
typed in or the decompiled expression. */ typed in or the decompiled expression. */
b->cond_string = savestring (arg, strlen (arg)); b->cond_string = xstrdup (arg);
b->condition_not_parsed = 0; b->condition_not_parsed = 0;
for (loc = b->loc; loc; loc = loc->next) for (loc = b->loc; loc; loc = loc->next)
{ {
@ -4394,8 +4394,7 @@ set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
if (sal.symtab == NULL) if (sal.symtab == NULL)
b->source_file = NULL; b->source_file = NULL;
else else
b->source_file = savestring (sal.symtab->filename, b->source_file = xstrdup (sal.symtab->filename);
strlen (sal.symtab->filename));
b->loc->section = sal.section; b->loc->section = sal.section;
b->line_number = sal.line; b->line_number = sal.line;
@ -4816,8 +4815,7 @@ create_catchpoint (int tempflag, char *cond_string,
set_breakpoint_count (breakpoint_count + 1); set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count; b->number = breakpoint_count;
b->cond_string = (cond_string == NULL) ? b->cond_string = (cond_string == NULL) ? NULL : xstrdup (cond_string);
NULL : savestring (cond_string, strlen (cond_string));
b->thread = -1; b->thread = -1;
b->addr_string = NULL; b->addr_string = NULL;
b->enable_state = bp_enabled; b->enable_state = bp_enabled;
@ -7490,9 +7488,7 @@ update_breakpoint_locations (struct breakpoint *b,
if (sals.sals[i].symtab == NULL) if (sals.sals[i].symtab == NULL)
b->source_file = NULL; b->source_file = NULL;
else else
b->source_file = b->source_file = xstrdup (sals.sals[i].symtab->filename);
savestring (sals.sals[i].symtab->filename,
strlen (sals.sals[i].symtab->filename));
if (b->line_number == 0) if (b->line_number == 0)
b->line_number = sals.sals[i].line; b->line_number = sals.sals[i].line;

View file

@ -561,9 +561,8 @@ start_subfile (char *name, char *dirname)
current_subfile = subfile; current_subfile = subfile;
/* Save its name and compilation directory name */ /* Save its name and compilation directory name */
subfile->name = (name == NULL) ? NULL : savestring (name, strlen (name)); subfile->name = (name == NULL) ? NULL : xstrdup (name);
subfile->dirname = subfile->dirname = (dirname == NULL) ? NULL : xstrdup (dirname);
(dirname == NULL) ? NULL : savestring (dirname, strlen (dirname));
/* Initialize line-number recording for this subfile. */ /* Initialize line-number recording for this subfile. */
subfile->line_vector = NULL; subfile->line_vector = NULL;
@ -638,7 +637,7 @@ patch_subfile_names (struct subfile *subfile, char *name)
&& subfile->name[strlen (subfile->name) - 1] == '/') && subfile->name[strlen (subfile->name) - 1] == '/')
{ {
subfile->dirname = subfile->name; subfile->dirname = subfile->name;
subfile->name = savestring (name, strlen (name)); subfile->name = xstrdup (name);
last_source_file = name; last_source_file = name;
/* Default the source language to whatever can be deduced from /* Default the source language to whatever can be deduced from
@ -1260,7 +1259,7 @@ hashname (char *name)
void void
record_debugformat (char *format) record_debugformat (char *format)
{ {
current_subfile->debugformat = savestring (format, strlen (format)); current_subfile->debugformat = xstrdup (format);
} }
void void
@ -1271,7 +1270,7 @@ record_producer (const char *producer)
if (producer == NULL) if (producer == NULL)
return; return;
current_subfile->producer = savestring (producer, strlen (producer)); current_subfile->producer = xstrdup (producer);
} }
/* Merge the first symbol list SRCLIST into the second symbol list /* Merge the first symbol list SRCLIST into the second symbol list

View file

@ -94,7 +94,7 @@ build_command_line (enum command_control_type type, char *args)
= (struct command_line **) xmalloc (sizeof (struct command_line *) = (struct command_line **) xmalloc (sizeof (struct command_line *)
* cmd->body_count); * cmd->body_count);
memset (cmd->body_list, 0, sizeof (struct command_line *) * cmd->body_count); memset (cmd->body_list, 0, sizeof (struct command_line *) * cmd->body_count);
cmd->line = savestring (args, strlen (args)); cmd->line = xstrdup (args);
return cmd; return cmd;
} }
@ -1384,7 +1384,7 @@ define_command (char *comname, int from_tty)
} }
} }
comname = savestring (comname, strlen (comname)); comname = xstrdup (comname);
/* If the rest of the commands will be case insensitive, this one /* If the rest of the commands will be case insensitive, this one
should behave in the same manner. */ should behave in the same manner. */
@ -1400,7 +1400,7 @@ define_command (char *comname, int from_tty)
newc = add_cmd (comname, class_user, user_defined_command, newc = add_cmd (comname, class_user, user_defined_command,
(c && c->class == class_user) (c && c->class == class_user)
? c->doc : savestring ("User-defined.", 13), list); ? c->doc : xstrdup ("User-defined."), list);
newc->user_commands = cmds; newc->user_commands = cmds;
/* If this new command is a hook, then mark both commands as being /* If this new command is a hook, then mark both commands as being

View file

@ -177,14 +177,14 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
arg = ""; arg = "";
if (*(char **) c->var != NULL) if (*(char **) c->var != NULL)
xfree (*(char **) c->var); xfree (*(char **) c->var);
*(char **) c->var = savestring (arg, strlen (arg)); *(char **) c->var = xstrdup (arg);
break; break;
case var_optional_filename: case var_optional_filename:
if (arg == NULL) if (arg == NULL)
arg = ""; arg = "";
if (*(char **) c->var != NULL) if (*(char **) c->var != NULL)
xfree (*(char **) c->var); xfree (*(char **) c->var);
*(char **) c->var = savestring (arg, strlen (arg)); *(char **) c->var = xstrdup (arg);
break; break;
case var_filename: case var_filename:
if (arg == NULL) if (arg == NULL)

View file

@ -364,7 +364,7 @@ coff_start_symtab (char *name)
this pointer into last_source_file and we put it in this pointer into last_source_file and we put it in
subfiles->name, which end_symtab frees; that's why subfiles->name, which end_symtab frees; that's why
it must be malloc'd. */ it must be malloc'd. */
savestring (name, strlen (name)), xstrdup (name),
/* We never know the directory name for COFF. */ /* We never know the directory name for COFF. */
NULL, NULL,
/* The start address is irrelevant, since we set /* The start address is irrelevant, since we set
@ -383,7 +383,7 @@ complete_symtab (char *name, CORE_ADDR start_addr, unsigned int size)
{ {
if (last_source_file != NULL) if (last_source_file != NULL)
xfree (last_source_file); xfree (last_source_file);
last_source_file = savestring (name, strlen (name)); last_source_file = xstrdup (name);
current_source_start_addr = start_addr; current_source_start_addr = start_addr;
current_source_end_addr = start_addr + size; current_source_end_addr = start_addr + size;
} }

View file

@ -399,7 +399,7 @@ set_gnutarget (char *newtarget)
{ {
if (gnutarget_string != NULL) if (gnutarget_string != NULL)
xfree (gnutarget_string); xfree (gnutarget_string);
gnutarget_string = savestring (newtarget, strlen (newtarget)); gnutarget_string = xstrdup (newtarget);
set_gnutarget_command (NULL, 0, NULL); set_gnutarget_command (NULL, 0, NULL);
} }

View file

@ -395,7 +395,7 @@ add_new_header_file (char *name, int instance)
i = N_HEADER_FILES (current_objfile)++; i = N_HEADER_FILES (current_objfile)++;
hfile = HEADER_FILES (current_objfile) + i; hfile = HEADER_FILES (current_objfile) + i;
hfile->name = savestring (name, strlen (name)); hfile->name = xstrdup (name);
hfile->instance = instance; hfile->instance = instance;
hfile->length = 10; hfile->length = 10;
hfile->vector hfile->vector

View file

@ -125,8 +125,7 @@ set_demangling_command (char *ignore, int from_tty, struct cmd_list_element *c)
{ {
xfree (current_demangling_style_string); xfree (current_demangling_style_string);
current_demangling_style_string = current_demangling_style_string =
savestring (dem->demangling_style_name, xstrdup (dem->demangling_style_name);
strlen (dem->demangling_style_name));
} }
} }
if (current_demangling_style == unknown_demangling) if (current_demangling_style == unknown_demangling)
@ -136,9 +135,7 @@ set_demangling_command (char *ignore, int from_tty, struct cmd_list_element *c)
one as the default. */ one as the default. */
current_demangling_style = libiberty_demanglers[0].demangling_style; current_demangling_style = libiberty_demanglers[0].demangling_style;
current_demangling_style_string = current_demangling_style_string =
savestring ( xstrdup (libiberty_demanglers[0].demangling_style_name);
libiberty_demanglers[0].demangling_style_name,
strlen (libiberty_demanglers[0].demangling_style_name));
warning (_("`%s' style demangling chosen as the default."), warning (_("`%s' style demangling chosen as the default."),
current_demangling_style_string); current_demangling_style_string);
} }
@ -154,7 +151,7 @@ set_demangling_style (char *style)
{ {
xfree (current_demangling_style_string); xfree (current_demangling_style_string);
} }
current_demangling_style_string = savestring (style, strlen (style)); current_demangling_style_string = xstrdup (style);
set_demangling_command ((char *) NULL, 0, (struct cmd_list_element *) NULL); set_demangling_command ((char *) NULL, 0, (struct cmd_list_element *) NULL);
} }

View file

@ -372,22 +372,22 @@ change_annotation_level (void)
/* Pushes a new prompt on the prompt stack. Each prompt has three /* Pushes a new prompt on the prompt stack. Each prompt has three
parts: prefix, prompt, suffix. Usually prefix and suffix are empty parts: prefix, prompt, suffix. Usually prefix and suffix are empty
strings, except when the annotation level is 2. Memory is allocated strings, except when the annotation level is 2. Memory is allocated
within savestring for the new prompt. */ within xstrdup for the new prompt. */
void void
push_prompt (char *prefix, char *prompt, char *suffix) push_prompt (char *prefix, char *prompt, char *suffix)
{ {
the_prompts.top++; the_prompts.top++;
PREFIX (0) = savestring (prefix, strlen (prefix)); PREFIX (0) = xstrdup (prefix);
/* Note that this function is used by the set annotate 2 /* Note that this function is used by the set annotate 2
command. This is why we take care of saving the old prompt command. This is why we take care of saving the old prompt
in case a new one is not specified. */ in case a new one is not specified. */
if (prompt) if (prompt)
PROMPT (0) = savestring (prompt, strlen (prompt)); PROMPT (0) = xstrdup (prompt);
else else
PROMPT (0) = savestring (PROMPT (-1), strlen (PROMPT (-1))); PROMPT (0) = xstrdup (PROMPT (-1));
SUFFIX (0) = savestring (suffix, strlen (suffix)); SUFFIX (0) = xstrdup (suffix);
} }
/* Pops the top of the prompt stack, and frees the memory allocated for it. */ /* Pops the top of the prompt stack, and frees the memory allocated for it. */
@ -404,7 +404,7 @@ pop_prompt (void)
if (strcmp (PROMPT (0), PROMPT (-1))) if (strcmp (PROMPT (0), PROMPT (-1)))
{ {
xfree (PROMPT (-1)); xfree (PROMPT (-1));
PROMPT (-1) = savestring (PROMPT (0), strlen (PROMPT (0))); PROMPT (-1) = xstrdup (PROMPT (0));
} }
xfree (PREFIX (0)); xfree (PREFIX (0));
@ -624,8 +624,7 @@ command_line_handler (char *rl)
{ {
p--; /* Put on top of '\'. */ p--; /* Put on top of '\'. */
readline_input_state.linebuffer = savestring (linebuffer, readline_input_state.linebuffer = xstrdup (linebuffer);
strlen (linebuffer));
readline_input_state.linebuffer_ptr = p; readline_input_state.linebuffer_ptr = p;
/* We will not invoke a execute_command if there is more /* We will not invoke a execute_command if there is more
@ -1063,7 +1062,7 @@ set_async_annotation_level (char *args, int from_tty, struct cmd_list_element *c
void void
set_async_prompt (char *args, int from_tty, struct cmd_list_element *c) set_async_prompt (char *args, int from_tty, struct cmd_list_element *c)
{ {
PROMPT (0) = savestring (new_async_prompt, strlen (new_async_prompt)); PROMPT (0) = xstrdup (new_async_prompt);
} }
/* Set things up for readline to be invoked via the alternate /* Set things up for readline to be invoked via the alternate

View file

@ -178,7 +178,7 @@ set_inferior_io_terminal (const char *terminal_name)
if (!terminal_name) if (!terminal_name)
inferior_io_terminal = NULL; inferior_io_terminal = NULL;
else else
inferior_io_terminal = savestring (terminal_name, strlen (terminal_name)); inferior_io_terminal = xstrdup (terminal_name);
} }
const char * const char *
@ -2154,7 +2154,7 @@ attach_command_post_wait (char *args, int from_tty, int async_exec)
filename. Not much more we can do...) filename. Not much more we can do...)
*/ */
if (!source_full_path_of (exec_file, &full_exec_path)) if (!source_full_path_of (exec_file, &full_exec_path))
full_exec_path = savestring (exec_file, strlen (exec_file)); full_exec_path = xstrdup (exec_file);
exec_file_attach (full_exec_path, from_tty); exec_file_attach (full_exec_path, from_tty);
symbol_file_add_main (full_exec_path, from_tty); symbol_file_add_main (full_exec_path, from_tty);

View file

@ -215,7 +215,7 @@ local or auto Automatic setting based on source file\n"));
/* Reset the language (esp. the global string "language") to the /* Reset the language (esp. the global string "language") to the
correct values. */ correct values. */
err_lang = savestring (language, strlen (language)); err_lang = xstrdup (language);
make_cleanup (xfree, err_lang); /* Free it after error */ make_cleanup (xfree, err_lang); /* Free it after error */
set_language (current_language->la_language); set_language (current_language->la_language);
error (_("Unknown language `%s'."), err_lang); error (_("Unknown language `%s'."), err_lang);
@ -1401,10 +1401,10 @@ For Fortran the default is off; for other languages the default is on."),
add_language (&local_language_defn); add_language (&local_language_defn);
add_language (&auto_language_defn); add_language (&auto_language_defn);
language = savestring ("auto", strlen ("auto")); language = xstrdup ("auto");
type = savestring ("auto", strlen ("auto")); type = xstrdup ("auto");
range = savestring ("auto", strlen ("auto")); range = xstrdup ("auto");
case_sensitive = savestring ("auto",strlen ("auto")); case_sensitive = xstrdup ("auto");
/* Have the above take effect */ /* Have the above take effect */
set_language (language_auto); set_language (language_auto);

View file

@ -587,7 +587,7 @@ See set/show multiple-symbol."));
if (canonical_arr[i] == NULL) if (canonical_arr[i] == NULL)
{ {
symname = SYMBOL_LINKAGE_NAME (sym_arr[i]); symname = SYMBOL_LINKAGE_NAME (sym_arr[i]);
canonical_arr[i] = savestring (symname, strlen (symname)); canonical_arr[i] = xstrdup (symname);
} }
} }
} }
@ -611,7 +611,7 @@ See set/show multiple-symbol."));
{ {
symname = SYMBOL_LINKAGE_NAME (sym_arr[num]); symname = SYMBOL_LINKAGE_NAME (sym_arr[num]);
make_cleanup (xfree, symname); make_cleanup (xfree, symname);
canonical_arr[i] = savestring (symname, strlen (symname)); canonical_arr[i] = xstrdup (symname);
} }
return_values.sals[i++] = values.sals[num]; return_values.sals[i++] = values.sals[num];
values.sals[num].pc = 0; values.sals[num].pc = 0;

View file

@ -736,8 +736,8 @@ add_vmap (LdInfo *ldi)
filename = LDI_FILENAME (ldi, arch64); filename = LDI_FILENAME (ldi, arch64);
mem = filename + strlen (filename) + 1; mem = filename + strlen (filename) + 1;
mem = savestring (mem, strlen (mem)); mem = xstrdup (mem);
objname = savestring (filename, strlen (filename)); objname = xstrdup (filename);
fd = LDI_FD (ldi, arch64); fd = LDI_FD (ldi, arch64);
if (fd < 0) if (fd < 0)

View file

@ -1153,11 +1153,11 @@ void
set_prompt (char *s) set_prompt (char *s)
{ {
/* ??rehrauer: I don't know why this fails, since it looks as though /* ??rehrauer: I don't know why this fails, since it looks as though
assignments to prompt are wrapped in calls to savestring... assignments to prompt are wrapped in calls to xstrdup...
if (prompt != NULL) if (prompt != NULL)
xfree (prompt); xfree (prompt);
*/ */
PROMPT (0) = savestring (s, strlen (s)); PROMPT (0) = xstrdup (s);
} }
@ -1458,7 +1458,7 @@ init_history (void)
tmpenv = getenv ("GDBHISTFILE"); tmpenv = getenv ("GDBHISTFILE");
if (tmpenv) if (tmpenv)
history_filename = savestring (tmpenv, strlen (tmpenv)); history_filename = xstrdup (tmpenv);
else if (!history_filename) else if (!history_filename)
{ {
/* We include the current directory so that if the user changes /* We include the current directory so that if the user changes
@ -1516,13 +1516,13 @@ init_main (void)
whatever the DEFAULT_PROMPT is. */ whatever the DEFAULT_PROMPT is. */
the_prompts.top = 0; the_prompts.top = 0;
PREFIX (0) = ""; PREFIX (0) = "";
PROMPT (0) = savestring (DEFAULT_PROMPT, strlen (DEFAULT_PROMPT)); PROMPT (0) = xstrdup (DEFAULT_PROMPT);
SUFFIX (0) = ""; SUFFIX (0) = "";
/* Set things up for annotation_level > 1, if the user ever decides /* Set things up for annotation_level > 1, if the user ever decides
to use it. */ to use it. */
async_annotation_suffix = "prompt"; async_annotation_suffix = "prompt";
/* Set the variable associated with the setshow prompt command. */ /* Set the variable associated with the setshow prompt command. */
new_async_prompt = savestring (PROMPT (0), strlen (PROMPT (0))); new_async_prompt = xstrdup (PROMPT (0));
/* If gdb was started with --annotate=2, this is equivalent to the /* If gdb was started with --annotate=2, this is equivalent to the
user entering the command 'set annotate 2' at the gdb prompt, so user entering the command 'set annotate 2' at the gdb prompt, so

View file

@ -938,7 +938,7 @@ stringify_collection_list (struct collection_list *list, char *string)
sprintf (end, "%02X", list->regs_mask[i]); sprintf (end, "%02X", list->regs_mask[i]);
end += 2; end += 2;
} }
(*str_list)[ndx] = savestring (temp_buf, end - temp_buf); (*str_list)[ndx] = xstrdup (temp_buf);
ndx++; ndx++;
} }
if (info_verbose) if (info_verbose)

View file

@ -461,7 +461,6 @@ varobj_create (char *objname,
char *p; char *p;
enum varobj_languages lang; enum varobj_languages lang;
struct value *value = NULL; struct value *value = NULL;
int expr_len;
/* Parse and evaluate the expression, filling in as much of the /* Parse and evaluate the expression, filling in as much of the
variable's data as possible. */ variable's data as possible. */
@ -512,10 +511,9 @@ varobj_create (char *objname,
var->format = variable_default_display (var); var->format = variable_default_display (var);
var->root->valid_block = innermost_block; var->root->valid_block = innermost_block;
expr_len = strlen (expression); var->name = xstrdup (expression);
var->name = savestring (expression, expr_len);
/* For a root var, the name and the expr are the same. */ /* For a root var, the name and the expr are the same. */
var->path_expr = savestring (expression, expr_len); var->path_expr = xstrdup (expression);
/* When the frame is different from the current frame, /* When the frame is different from the current frame,
we must select the appropriate frame before parsing we must select the appropriate frame before parsing
@ -561,7 +559,7 @@ varobj_create (char *objname,
if ((var != NULL) && (objname != NULL)) if ((var != NULL) && (objname != NULL))
{ {
var->obj_name = savestring (objname, strlen (objname)); var->obj_name = xstrdup (objname);
/* If a varobj name is duplicated, the install will fail so /* If a varobj name is duplicated, the install will fail so
we must clenup */ we must clenup */
@ -1765,8 +1763,7 @@ value_of_root (struct varobj **var_handle, int *type_changed)
} }
else else
{ {
tmp_var->obj_name = tmp_var->obj_name = xstrdup (var->obj_name);
savestring (var->obj_name, strlen (var->obj_name));
varobj_delete (var, NULL, 0); varobj_delete (var, NULL, 0);
install_variable (tmp_var); install_variable (tmp_var);
@ -2015,7 +2012,7 @@ c_number_of_children (struct varobj *var)
static char * static char *
c_name_of_variable (struct varobj *parent) c_name_of_variable (struct varobj *parent)
{ {
return savestring (parent->name, strlen (parent->name)); return xstrdup (parent->name);
} }
/* Return the value of element TYPE_INDEX of a structure /* Return the value of element TYPE_INDEX of a structure
@ -2114,10 +2111,7 @@ c_describe_child (struct varobj *parent, int index,
case TYPE_CODE_STRUCT: case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION: case TYPE_CODE_UNION:
if (cname) if (cname)
{ *cname = xstrdup (TYPE_FIELD_NAME (type, index));
char *string = TYPE_FIELD_NAME (type, index);
*cname = savestring (string, strlen (string));
}
if (cvalue && value) if (cvalue && value)
{ {

View file

@ -831,8 +831,8 @@ enter_line_range (struct subfile *subfile, unsigned beginoffset, unsigned endoff
text address for the file, and SIZE is the number of bytes of text. */ text address for the file, and SIZE is the number of bytes of text. */
#define complete_symtab(name, start_addr) { \ #define complete_symtab(name, start_addr) { \
last_source_file = savestring (name, strlen (name)); \ last_source_file = xstrdup (name); \
last_source_start_addr = start_addr; \ last_source_start_addr = start_addr; \
} }