aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-10-31 10:46:18 -0600
committerTom Tromey <tromey@adacore.com>2020-01-08 11:17:18 -0700
commit456e800a63def18484f69a51f59c2338a5cc4568 (patch)
treec55fe313258a4cacd3237f33355f86b3bf55934f
parent6dfa2fc20773615c3a08c3565974dcfdfa36f052 (diff)
downloadgdb-456e800a63def18484f69a51f59c2338a5cc4568.zip
gdb-456e800a63def18484f69a51f59c2338a5cc4568.tar.gz
gdb-456e800a63def18484f69a51f59c2338a5cc4568.tar.bz2
Use std::string in dwarf2read.c
This replaces two instances of manual string management in dwarf2read.c with std::string. gdb/ChangeLog 2020-01-08 Tom Tromey <tromey@adacore.com> * dwarf2read.c (parse_macro_definition): Use std::string. (parse_macro_definition): Likewise. Change-Id: Iec437100105484aa4a116fb5d651d7ed52ee9d81
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/dwarf2read.c13
2 files changed, 10 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 118d6d7..9733a10 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2020-01-08 Tom Tromey <tromey@adacore.com>
+ * dwarf2read.c (parse_macro_definition): Use std::string.
+ (parse_macro_definition): Likewise.
+
+2020-01-08 Tom Tromey <tromey@adacore.com>
+
* dwarf2read.c (abbrev_table_read_table): Use std::vector.
(ATTR_ALLOC_CHUNK): Remove.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 5a194f4..40af0b9 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -24570,7 +24570,7 @@ parse_macro_definition (struct macro_source_file *file, int line,
{
/* It's an object-like macro. */
int name_len = p - body;
- char *name = savestring (body, name_len);
+ std::string name (body, name_len);
const char *replacement;
if (*p == ' ')
@@ -24581,14 +24581,12 @@ parse_macro_definition (struct macro_source_file *file, int line,
replacement = body + name_len;
}
- macro_define_object (file, line, name, replacement);
-
- xfree (name);
+ macro_define_object (file, line, name.c_str (), replacement);
}
else if (*p == '(')
{
/* It's a function-like macro. */
- char *name = savestring (body, p - body);
+ std::string name (body, p - body);
int argc = 0;
int argv_size = 1;
char **argv = XNEWVEC (char *, argv_size);
@@ -24637,14 +24635,14 @@ parse_macro_definition (struct macro_source_file *file, int line,
if (*p == ' ')
/* Perfectly formed definition, no complaints. */
- macro_define_function (file, line, name,
+ macro_define_function (file, line, name.c_str (),
argc, (const char **) argv,
p + 1);
else if (*p == '\0')
{
/* Complain, but do define it. */
dwarf2_macro_malformed_definition_complaint (body);
- macro_define_function (file, line, name,
+ macro_define_function (file, line, name.c_str (),
argc, (const char **) argv,
p);
}
@@ -24656,7 +24654,6 @@ parse_macro_definition (struct macro_source_file *file, int line,
/* Just complain. */
dwarf2_macro_malformed_definition_complaint (body);
- xfree (name);
{
int i;