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>
+
+ 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>
Remove already unreachable code.
arg = p;
/* I don't know if it matters whether this is the string the user
typed in or the decompiled expression. */
- b->cond_string = savestring (arg, strlen (arg));
+ b->cond_string = xstrdup (arg);
b->condition_not_parsed = 0;
for (loc = b->loc; loc; loc = loc->next)
{
if (sal.symtab == NULL)
b->source_file = NULL;
else
- b->source_file = savestring (sal.symtab->filename,
- strlen (sal.symtab->filename));
+ b->source_file = xstrdup (sal.symtab->filename);
b->loc->section = sal.section;
b->line_number = sal.line;
set_breakpoint_count (breakpoint_count + 1);
b->number = breakpoint_count;
- b->cond_string = (cond_string == NULL) ?
- NULL : savestring (cond_string, strlen (cond_string));
+ b->cond_string = (cond_string == NULL) ? NULL : xstrdup (cond_string);
b->thread = -1;
b->addr_string = NULL;
b->enable_state = bp_enabled;
if (sals.sals[i].symtab == NULL)
b->source_file = NULL;
else
- b->source_file =
- savestring (sals.sals[i].symtab->filename,
- strlen (sals.sals[i].symtab->filename));
+ b->source_file = xstrdup (sals.sals[i].symtab->filename);
if (b->line_number == 0)
b->line_number = sals.sals[i].line;
current_subfile = subfile;
/* Save its name and compilation directory name */
- subfile->name = (name == NULL) ? NULL : savestring (name, strlen (name));
- subfile->dirname =
- (dirname == NULL) ? NULL : savestring (dirname, strlen (dirname));
+ subfile->name = (name == NULL) ? NULL : xstrdup (name);
+ subfile->dirname = (dirname == NULL) ? NULL : xstrdup (dirname);
/* Initialize line-number recording for this subfile. */
subfile->line_vector = NULL;
&& subfile->name[strlen (subfile->name) - 1] == '/')
{
subfile->dirname = subfile->name;
- subfile->name = savestring (name, strlen (name));
+ subfile->name = xstrdup (name);
last_source_file = name;
/* Default the source language to whatever can be deduced from
void
record_debugformat (char *format)
{
- current_subfile->debugformat = savestring (format, strlen (format));
+ current_subfile->debugformat = xstrdup (format);
}
void
if (producer == NULL)
return;
- current_subfile->producer = savestring (producer, strlen (producer));
+ current_subfile->producer = xstrdup (producer);
}
/* Merge the first symbol list SRCLIST into the second symbol 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->line = savestring (args, strlen (args));
+ cmd->line = xstrdup (args);
return cmd;
}
}
}
- comname = savestring (comname, strlen (comname));
+ comname = xstrdup (comname);
/* If the rest of the commands will be case insensitive, this one
should behave in the same manner. */
newc = add_cmd (comname, class_user, user_defined_command,
(c && c->class == class_user)
- ? c->doc : savestring ("User-defined.", 13), list);
+ ? c->doc : xstrdup ("User-defined."), list);
newc->user_commands = cmds;
/* If this new command is a hook, then mark both commands as being
arg = "";
if (*(char **) c->var != NULL)
xfree (*(char **) c->var);
- *(char **) c->var = savestring (arg, strlen (arg));
+ *(char **) c->var = xstrdup (arg);
break;
case var_optional_filename:
if (arg == NULL)
arg = "";
if (*(char **) c->var != NULL)
xfree (*(char **) c->var);
- *(char **) c->var = savestring (arg, strlen (arg));
+ *(char **) c->var = xstrdup (arg);
break;
case var_filename:
if (arg == NULL)
this pointer into last_source_file and we put it in
subfiles->name, which end_symtab frees; that's why
it must be malloc'd. */
- savestring (name, strlen (name)),
+ xstrdup (name),
/* We never know the directory name for COFF. */
NULL,
/* The start address is irrelevant, since we set
{
if (last_source_file != NULL)
xfree (last_source_file);
- last_source_file = savestring (name, strlen (name));
+ last_source_file = xstrdup (name);
current_source_start_addr = start_addr;
current_source_end_addr = start_addr + size;
}
{
if (gnutarget_string != NULL)
xfree (gnutarget_string);
- gnutarget_string = savestring (newtarget, strlen (newtarget));
+ gnutarget_string = xstrdup (newtarget);
set_gnutarget_command (NULL, 0, NULL);
}
i = N_HEADER_FILES (current_objfile)++;
hfile = HEADER_FILES (current_objfile) + i;
- hfile->name = savestring (name, strlen (name));
+ hfile->name = xstrdup (name);
hfile->instance = instance;
hfile->length = 10;
hfile->vector
{
xfree (current_demangling_style_string);
current_demangling_style_string =
- savestring (dem->demangling_style_name,
- strlen (dem->demangling_style_name));
+ xstrdup (dem->demangling_style_name);
}
}
if (current_demangling_style == unknown_demangling)
one as the default. */
current_demangling_style = libiberty_demanglers[0].demangling_style;
current_demangling_style_string =
- savestring (
- libiberty_demanglers[0].demangling_style_name,
- strlen (libiberty_demanglers[0].demangling_style_name));
+ xstrdup (libiberty_demanglers[0].demangling_style_name);
warning (_("`%s' style demangling chosen as the default."),
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);
}
/* Pushes a new prompt on the prompt stack. Each prompt has three
parts: prefix, prompt, suffix. Usually prefix and suffix are empty
strings, except when the annotation level is 2. Memory is allocated
- within savestring for the new prompt. */
+ within xstrdup for the new prompt. */
void
push_prompt (char *prefix, char *prompt, char *suffix)
{
the_prompts.top++;
- PREFIX (0) = savestring (prefix, strlen (prefix));
+ PREFIX (0) = xstrdup (prefix);
/* Note that this function is used by the set annotate 2
command. This is why we take care of saving the old prompt
in case a new one is not specified. */
if (prompt)
- PROMPT (0) = savestring (prompt, strlen (prompt));
+ PROMPT (0) = xstrdup (prompt);
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. */
if (strcmp (PROMPT (0), PROMPT (-1)))
{
xfree (PROMPT (-1));
- PROMPT (-1) = savestring (PROMPT (0), strlen (PROMPT (0)));
+ PROMPT (-1) = xstrdup (PROMPT (0));
}
xfree (PREFIX (0));
{
p--; /* Put on top of '\'. */
- readline_input_state.linebuffer = savestring (linebuffer,
- strlen (linebuffer));
+ readline_input_state.linebuffer = xstrdup (linebuffer);
readline_input_state.linebuffer_ptr = p;
/* We will not invoke a execute_command if there is more
void
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
if (!terminal_name)
inferior_io_terminal = NULL;
else
- inferior_io_terminal = savestring (terminal_name, strlen (terminal_name));
+ inferior_io_terminal = xstrdup (terminal_name);
}
const char *
filename. Not much more we can do...)
*/
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);
symbol_file_add_main (full_exec_path, from_tty);
/* Reset the language (esp. the global string "language") to the
correct values. */
- err_lang = savestring (language, strlen (language));
+ err_lang = xstrdup (language);
make_cleanup (xfree, err_lang); /* Free it after error */
set_language (current_language->la_language);
error (_("Unknown language `%s'."), err_lang);
add_language (&local_language_defn);
add_language (&auto_language_defn);
- language = savestring ("auto", strlen ("auto"));
- type = savestring ("auto", strlen ("auto"));
- range = savestring ("auto", strlen ("auto"));
- case_sensitive = savestring ("auto",strlen ("auto"));
+ language = xstrdup ("auto");
+ type = xstrdup ("auto");
+ range = xstrdup ("auto");
+ case_sensitive = xstrdup ("auto");
/* Have the above take effect */
set_language (language_auto);
if (canonical_arr[i] == NULL)
{
symname = SYMBOL_LINKAGE_NAME (sym_arr[i]);
- canonical_arr[i] = savestring (symname, strlen (symname));
+ canonical_arr[i] = xstrdup (symname);
}
}
}
{
symname = SYMBOL_LINKAGE_NAME (sym_arr[num]);
make_cleanup (xfree, symname);
- canonical_arr[i] = savestring (symname, strlen (symname));
+ canonical_arr[i] = xstrdup (symname);
}
return_values.sals[i++] = values.sals[num];
values.sals[num].pc = 0;
filename = LDI_FILENAME (ldi, arch64);
mem = filename + strlen (filename) + 1;
- mem = savestring (mem, strlen (mem));
- objname = savestring (filename, strlen (filename));
+ mem = xstrdup (mem);
+ objname = xstrdup (filename);
fd = LDI_FD (ldi, arch64);
if (fd < 0)
set_prompt (char *s)
{
/* ??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)
xfree (prompt);
*/
- PROMPT (0) = savestring (s, strlen (s));
+ PROMPT (0) = xstrdup (s);
}
\f
tmpenv = getenv ("GDBHISTFILE");
if (tmpenv)
- history_filename = savestring (tmpenv, strlen (tmpenv));
+ history_filename = xstrdup (tmpenv);
else if (!history_filename)
{
/* We include the current directory so that if the user changes
whatever the DEFAULT_PROMPT is. */
the_prompts.top = 0;
PREFIX (0) = "";
- PROMPT (0) = savestring (DEFAULT_PROMPT, strlen (DEFAULT_PROMPT));
+ PROMPT (0) = xstrdup (DEFAULT_PROMPT);
SUFFIX (0) = "";
/* Set things up for annotation_level > 1, if the user ever decides
to use it. */
async_annotation_suffix = "prompt";
/* 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
user entering the command 'set annotate 2' at the gdb prompt, so
sprintf (end, "%02X", list->regs_mask[i]);
end += 2;
}
- (*str_list)[ndx] = savestring (temp_buf, end - temp_buf);
+ (*str_list)[ndx] = xstrdup (temp_buf);
ndx++;
}
if (info_verbose)
char *p;
enum varobj_languages lang;
struct value *value = NULL;
- int expr_len;
/* Parse and evaluate the expression, filling in as much of the
variable's data as possible. */
var->format = variable_default_display (var);
var->root->valid_block = innermost_block;
- expr_len = strlen (expression);
- var->name = savestring (expression, expr_len);
+ var->name = xstrdup (expression);
/* 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,
we must select the appropriate frame before parsing
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
we must clenup */
}
else
{
- tmp_var->obj_name =
- savestring (var->obj_name, strlen (var->obj_name));
+ tmp_var->obj_name = xstrdup (var->obj_name);
varobj_delete (var, NULL, 0);
install_variable (tmp_var);
static char *
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
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
if (cname)
- {
- char *string = TYPE_FIELD_NAME (type, index);
- *cname = savestring (string, strlen (string));
- }
+ *cname = xstrdup (TYPE_FIELD_NAME (type, index));
if (cvalue && value)
{
text address for the file, and SIZE is the number of bytes of text. */
#define complete_symtab(name, start_addr) { \
- last_source_file = savestring (name, strlen (name)); \
- last_source_start_addr = start_addr; \
+ last_source_file = xstrdup (name); \
+ last_source_start_addr = start_addr; \
}