aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-04-22 10:26:18 -0600
committerTom Tromey <tom@tromey.com>2018-10-04 22:51:46 -0600
commit795afcbbb4b6c9a47597b9da57221b1bf9fdc88f (patch)
tree3f053530a988c126f388db88bd64770c2c60aa6d
parentda4ae14a4d1614015f6e8d4a37df1b882806630a (diff)
downloadgdb-795afcbbb4b6c9a47597b9da57221b1bf9fdc88f.zip
gdb-795afcbbb4b6c9a47597b9da57221b1bf9fdc88f.tar.gz
gdb-795afcbbb4b6c9a47597b9da57221b1bf9fdc88f.tar.bz2
Use std::string in mdebugread.c
This changes a couple of spots in mdebugread to use std::string rather than manual management. This is simpler, and also avoids shadowing by renaming the variable in question. gdb/ChangeLog 2018-10-04 Tom Tromey <tom@tromey.com> * mdebugread.c (parse_partial_symbols): Use std::string.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/mdebugread.c20
2 files changed, 10 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6284051..0b5f35b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2018-10-04 Tom Tromey <tom@tromey.com>
+ * mdebugread.c (parse_partial_symbols): Use std::string.
+
+2018-10-04 Tom Tromey <tom@tromey.com>
+
* ctf.c (SET_ARRAY_FIELD): Rename "u32".
* p-valprint.c (pascal_val_print): Split inner "i" variable.
* xtensa-tdep.c (xtensa_push_dummy_call): Declare "i" in loop
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 453b8d5..62de80e 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3197,13 +3197,9 @@ parse_partial_symbols (minimal_symbol_reader &reader,
case 'f':
if (! pst)
{
- int name_len = p - namestring;
- char *name = (char *) xmalloc (name_len + 1);
-
- memcpy (name, namestring, name_len);
- name[name_len] = '\0';
- function_outside_compilation_unit_complaint (name);
- xfree (name);
+ std::string copy (namestring, p);
+ function_outside_compilation_unit_complaint
+ (copy.c_str ());
}
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_BLOCK,
@@ -3220,13 +3216,9 @@ parse_partial_symbols (minimal_symbol_reader &reader,
case 'F':
if (! pst)
{
- int name_len = p - namestring;
- char *name = (char *) xmalloc (name_len + 1);
-
- memcpy (name, namestring, name_len);
- name[name_len] = '\0';
- function_outside_compilation_unit_complaint (name);
- xfree (name);
+ std::string copy (namestring, p);
+ function_outside_compilation_unit_complaint
+ (copy.c_str ());
}
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_BLOCK,