This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfc] Replace strsave() with xstrdup()
- To: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: [rfc] Replace strsave() with xstrdup()
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Thu, 18 Jan 2001 13:45:13 +1100
Any comments?
Andrew
Thu Jan 18 13:22:51 2001 Andrew Cagney <cagney@b1.cygnus.com>
* defs.h (strsave): Delete declaration.
* utils.c (strsave): Delete definition.
* mac-xdep.c (tilde_expand): Replace strsave with xstrdup.
* sparcl-tdep.c (sparclite_open): Ditto.
* mips-tdep.c (mips_set_processor_type_command): Ditto.
(_initialize_mips_tdep): Ditto.
* solib.c (solib_open): Ditto.
* symfile.c (add_filename_language): Ditto.
(set_ext_lang_command): Ditto.
* source.c (init_source_path): Ditto.
(mod_path): Ditto.
* sh3-rom.c (sh3_open): Ditto.
(sh3e_open): Ditto.
* serial.c (serial_open): Ditto.
* remote-mips.c (common_open): Ditto.
* monitor.c (monitor_open): Ditto.
* m32r-rom.c (m32r_upload_command): Ditto.
* infcmd.c (path_command): Ditto.
* f-exp.y (parse_number): Ditto.
* breakpoint.c (create_longjmp_breakpoint): Ditto.
(create_thread_event_breakpoint): Ditto.
* arc-tdep.c (arc_set_cpu_type_command): Ditto.
(_initialize_arc_tdep): Ditto.
Index: arc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arc-tdep.c,v
retrieving revision 1.3
diff -u -r1.3 arc-tdep.c
--- arc-tdep.c 2000/07/30 01:48:24 1.3
+++ arc-tdep.c 2001/01/18 02:33:54
@@ -639,7 +639,7 @@
printf_unfiltered ("%s\n", arc_cpu_type_table[i].name);
/* Restore the value. */
- tmp_arc_cpu_type = strsave (arc_cpu_type);
+ tmp_arc_cpu_type = xstrdup (arc_cpu_type);
return;
}
@@ -648,7 +648,7 @@
{
error ("Unknown cpu type `%s'.", tmp_arc_cpu_type);
/* Restore its value. */
- tmp_arc_cpu_type = strsave (arc_cpu_type);
+ tmp_arc_cpu_type = xstrdup (arc_cpu_type);
}
}
@@ -698,9 +698,9 @@
c = add_show_from_set (c, &showlist);
c->function.cfunc = arc_show_cpu_type_command;
- /* We have to use strsave here because the `set' command frees it before
- setting a new value. */
- tmp_arc_cpu_type = strsave (DEFAULT_ARC_CPU_TYPE);
+ /* We have to use xstrdup() here because the `set' command frees it
+ before setting a new value. */
+ tmp_arc_cpu_type = xstrdup (DEFAULT_ARC_CPU_TYPE);
arc_set_cpu_type (tmp_arc_cpu_type);
c = add_set_cmd ("displaypipeline", class_support, var_zinteger,
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.22
diff -u -r1.22 breakpoint.c
--- breakpoint.c 2000/12/15 01:01:45 1.22
+++ breakpoint.c 2001/01/18 02:35:10
@@ -3871,7 +3871,7 @@
b->enable = disabled;
b->silent = 1;
if (func_name)
- b->addr_string = strsave (func_name);
+ b->addr_string = xstrdup (func_name);
b->number = internal_breakpoint_number--;
}
@@ -3928,7 +3928,7 @@
b->enable = enabled;
/* addr_string has to be used or breakpoint_re_set will delete me. */
sprintf (addr_string, "*0x%s", paddr (b->address));
- b->addr_string = strsave (addr_string);
+ b->addr_string = xstrdup (addr_string);
return b;
}
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.33
diff -u -r1.33 defs.h
--- defs.h 2000/12/15 01:01:46 1.33
+++ defs.h 2001/01/18 02:35:20
@@ -823,8 +823,6 @@
extern char *msavestring (void *, const char *, int);
-extern char *strsave (const char *);
-
extern char *mstrsave (void *, const char *);
/* FIXME; was long, but this causes compile errors in msvc if already
Index: f-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/f-exp.y,v
retrieving revision 1.2
diff -u -r1.2 f-exp.y
--- f-exp.y 2000/05/28 01:12:27 1.2
+++ f-exp.y 2001/01/18 02:35:25
@@ -653,7 +653,7 @@
/* [dD] is not understood as an exponent by atof, change it to 'e'. */
char *tmp, *tmp2;
- tmp = strsave (p);
+ tmp = xstrdup (p);
for (tmp2 = tmp; *tmp2; ++tmp2)
if (*tmp2 == 'd' || *tmp2 == 'D')
*tmp2 = 'e';
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.15
diff -u -r1.15 infcmd.c
--- infcmd.c 2001/01/12 09:45:57 1.15
+++ infcmd.c 2001/01/18 02:35:43
@@ -1420,7 +1420,7 @@
/* Can be null if path is not set */
if (!env)
env = "";
- exec_path = strsave (env);
+ exec_path = xstrdup (env);
mod_path (dirname, &exec_path);
set_in_environ (inferior_environ, path_var_name, exec_path);
xfree (exec_path);
Index: m32r-rom.c
===================================================================
RCS file: /cvs/src/src/gdb/m32r-rom.c,v
retrieving revision 1.4
diff -u -r1.4 m32r-rom.c
--- m32r-rom.c 2000/12/02 13:43:26 1.4
+++ m32r-rom.c 2001/01/18 02:35:43
@@ -480,7 +480,7 @@
error ("Please use 'set board-address' to set the M32R-EVA board's IP address.");
if (strchr (myIPaddress, '('))
*(strchr (myIPaddress, '(')) = '\0'; /* delete trailing junk */
- board_addr = strsave (myIPaddress);
+ board_addr = xstrdup (myIPaddress);
}
if (server_addr == 0)
{
@@ -508,7 +508,7 @@
if (args[0] != '/' && download_path == 0)
{
if (current_directory)
- download_path = strsave (current_directory);
+ download_path = xstrdup (current_directory);
else
error ("Need to know default download path (use 'set download-path')");
}
Index: mac-xdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mac-xdep.c,v
retrieving revision 1.2
diff -u -r1.2 mac-xdep.c
--- mac-xdep.c 2000/07/30 01:48:26 1.2
+++ mac-xdep.c 2001/01/18 02:35:43
@@ -926,7 +926,7 @@
char *
tilde_expand (char *str)
{
- return strsave (str);
+ return xstrdup (str);
}
/* Modified versions of standard I/O. */
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.38
diff -u -r1.38 mips-tdep.c
--- mips-tdep.c 2001/01/04 23:22:45 1.38
+++ mips-tdep.c 2001/01/18 02:36:20
@@ -3331,7 +3331,7 @@
printf_unfiltered ("%s\n", mips_processor_type_table[i].name);
/* Restore the value. */
- tmp_mips_processor_type = strsave (mips_processor_type);
+ tmp_mips_processor_type = xstrdup (mips_processor_type);
return;
}
@@ -3340,7 +3340,7 @@
{
error ("Unknown processor type `%s'.", tmp_mips_processor_type);
/* Restore its value. */
- tmp_mips_processor_type = strsave (mips_processor_type);
+ tmp_mips_processor_type = xstrdup (mips_processor_type);
}
}
@@ -4610,8 +4610,8 @@
c = add_show_from_set (c, &showlist);
c->function.cfunc = mips_show_processor_type_command;
- tmp_mips_processor_type = strsave (DEFAULT_MIPS_TYPE);
- mips_set_processor_type_command (strsave (DEFAULT_MIPS_TYPE), 0);
+ tmp_mips_processor_type = xstrdup (DEFAULT_MIPS_TYPE);
+ mips_set_processor_type_command (xstrdup (DEFAULT_MIPS_TYPE), 0);
#endif
/* We really would like to have both "0" and "unlimited" work, but
Index: monitor.c
===================================================================
RCS file: /cvs/src/src/gdb/monitor.c,v
retrieving revision 1.15
diff -u -r1.15 monitor.c
--- monitor.c 2000/12/15 01:01:48 1.15
+++ monitor.c 2001/01/18 02:36:35
@@ -753,7 +753,7 @@
if (dev_name)
xfree (dev_name);
- dev_name = strsave (args);
+ dev_name = xstrdup (args);
monitor_desc = SERIAL_OPEN (dev_name);
Index: remote-mips.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-mips.c,v
retrieving revision 1.11
diff -u -r1.11 remote-mips.c
--- remote-mips.c 2000/12/15 01:01:48 1.11
+++ remote-mips.c 2001/01/18 02:37:29
@@ -1528,7 +1528,7 @@
nomem (0);
make_cleanup_freeargv (argv);
- serial_port_name = strsave (argv[0]);
+ serial_port_name = xstrdup (argv[0]);
if (argv[1]) /* remote TFTP name specified? */
{
remote_name = argv[1];
@@ -1584,8 +1584,8 @@
local_name++; /* skip over the colon */
if (local_name == NULL)
local_name = remote_name; /* local name same as remote name */
- tftp_name = strsave (remote_name);
- tftp_localname = strsave (local_name);
+ tftp_name = xstrdup (remote_name);
+ tftp_localname = xstrdup (local_name);
tftp_in_use = 1;
}
}
@@ -1595,7 +1595,7 @@
/* Reset the expected monitor prompt if it's never been set before. */
if (mips_monitor_prompt == NULL)
- mips_monitor_prompt = strsave (new_monitor_prompt);
+ mips_monitor_prompt = xstrdup (new_monitor_prompt);
mips_monitor = new_monitor;
mips_initialize ();
@@ -1611,7 +1611,7 @@
/* Try to figure out the processor model if possible. */
ptype = mips_read_processor_type ();
if (ptype)
- mips_set_processor_type_command (strsave (ptype), 0);
+ mips_set_processor_type_command (xstrdup (ptype), 0);
/* This is really the job of start_remote however, that makes an assumption
that the target is about to print out a status message of some sort. That
Index: serial.c
===================================================================
RCS file: /cvs/src/src/gdb/serial.c,v
retrieving revision 1.6
diff -u -r1.6 serial.c
--- serial.c 2000/12/15 12:04:03 1.6
+++ serial.c 2001/01/18 02:37:36
@@ -213,7 +213,7 @@
return NULL;
}
- scb->name = strsave (name);
+ scb->name = xstrdup (name);
scb->next = scb_base;
scb->refcnt = 1;
scb->debug_p = 0;
Index: sh3-rom.c
===================================================================
RCS file: /cvs/src/src/gdb/sh3-rom.c,v
retrieving revision 1.5
diff -u -r1.5 sh3-rom.c
--- sh3-rom.c 2000/07/30 01:48:27 1.5
+++ sh3-rom.c 2001/01/18 02:37:36
@@ -249,7 +249,7 @@
if (args)
{
- char *cursor = serial_port_name = strsave (args);
+ char *cursor = serial_port_name = xstrdup (args);
while (*cursor && *cursor != ' ')
cursor++;
@@ -289,7 +289,7 @@
if (args)
{
- char *cursor = serial_port_name = strsave (args);
+ char *cursor = serial_port_name = xstrdup (args);
while (*cursor && *cursor != ' ')
cursor++;
Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.31
diff -u -r1.31 solib.c
--- solib.c 2000/12/23 00:27:20 1.31
+++ solib.c 2001/01/18 02:37:44
@@ -143,7 +143,7 @@
/* Done. If not found, tough luck. Return found_file and
(optionally) found_pathname. */
if (found_pathname != NULL && temp_pathname != NULL)
- *found_pathname = strsave (temp_pathname);
+ *found_pathname = xstrdup (temp_pathname);
return found_file;
}
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.7
diff -u -r1.7 source.c
--- source.c 2001/01/16 17:36:44 1.7
+++ source.c 2001/01/18 02:37:58
@@ -255,7 +255,7 @@
char buf[20];
sprintf (buf, "$cdir%c$cwd", DIRNAME_SEPARATOR);
- source_path = strsave (buf);
+ source_path = xstrdup (buf);
forget_cached_source_info ();
}
@@ -295,7 +295,7 @@
if (dirname == 0)
return;
- dirname = strsave (dirname);
+ dirname = xstrdup (dirname);
make_cleanup (xfree, dirname);
do
Index: sparcl-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparcl-tdep.c,v
retrieving revision 1.8
diff -u -r1.8 sparcl-tdep.c
--- sparcl-tdep.c 2000/12/15 01:01:49 1.8
+++ sparcl-tdep.c 2001/01/18 02:37:58
@@ -413,7 +413,7 @@
if (remote_target_name)
xfree (remote_target_name);
- remote_target_name = strsave (name);
+ remote_target_name = xstrdup (name);
/* We need a 'serial' or 'udp' keyword to disambiguate host:port, which can
mean either a serial port on a terminal server, or the IP address of a
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.22
diff -u -r1.22 symfile.c
--- symfile.c 2000/12/15 01:01:50 1.22
+++ symfile.c 2001/01/18 02:38:20
@@ -1783,7 +1783,7 @@
fl_table_size);
}
- filename_language_table[fl_table_next].ext = strsave (ext);
+ filename_language_table[fl_table_next].ext = xstrdup (ext);
filename_language_table[fl_table_next].lang = lang;
fl_table_next++;
}
@@ -1842,7 +1842,7 @@
/* ext_args, language_str (lang)); */
xfree (filename_language_table[i].ext);
- filename_language_table[i].ext = strsave (ext_args);
+ filename_language_table[i].ext = xstrdup (ext_args);
filename_language_table[i].lang = lang;
}
}
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.25
diff -u -r1.25 utils.c
--- utils.c 2000/12/15 01:01:50 1.25
+++ utils.c 2001/01/18 02:38:31
@@ -1162,15 +1162,6 @@
return p;
}
-/* The "const" is so it compiles under DGUX (which prototypes strsave
- in <string.h>. FIXME: This should be named "xstrsave", shouldn't it?
- Doesn't real strsave return NULL if out of memory? */
-char *
-strsave (const char *ptr)
-{
- return savestring (ptr, strlen (ptr));
-}
-
char *
mstrsave (void *md, const char *ptr)
{