This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Use unique_xmalloc_ptr in c_type_print_base
- From: Tom Tromey <tromey at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 4 Nov 2017 16:38:47 -0000
- Subject: [binutils-gdb] Use unique_xmalloc_ptr in c_type_print_base
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=331b71e5ee226cb5455969899274f0e43e83aa1e
commit 331b71e5ee226cb5455969899274f0e43e83aa1e
Author: Tom Tromey <tom@tromey.com>
Date: Wed Nov 1 19:16:58 2017 -0600
Use unique_xmalloc_ptr in c_type_print_base
This changes c_type_print_base to use unique_xmalloc_ptr, removing a
cleanup.
gdb/ChangeLog
2017-11-04 Tom Tromey <tom@tromey.com>
* c-typeprint.c (c_type_print_base): Use gdb::unique_xmalloc_ptr.
Diff:
---
gdb/ChangeLog | 4 ++++
gdb/c-typeprint.c | 13 +++----------
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d4b10a3..04fee5e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2017-11-04 Tom Tromey <tom@tromey.com>
+ * c-typeprint.c (c_type_print_base): Use gdb::unique_xmalloc_ptr.
+
+2017-11-04 Tom Tromey <tom@tromey.com>
+
* linux-tdep.c (linux_core_info_proc_mappings): Use
gdb::def_vector.
(linux_get_siginfo_data): Return gdb::byte_vector. Remove
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 22fdaa5..ed5a1a4 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -1218,8 +1218,8 @@ c_type_print_base (struct type *type, struct ui_file *stream,
for (j = 0; j < len2; j++)
{
const char *mangled_name;
+ gdb::unique_xmalloc_ptr<char> mangled_name_holder;
char *demangled_name;
- struct cleanup *inner_cleanup;
const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
int is_full_physname_constructor =
TYPE_FN_FIELD_CONSTRUCTOR (f, j)
@@ -1231,8 +1231,6 @@ c_type_print_base (struct type *type, struct ui_file *stream,
if (TYPE_FN_FIELD_ARTIFICIAL (f, j))
continue;
- inner_cleanup = make_cleanup (null_cleanup, NULL);
-
QUIT;
section_type = output_access_specifier
(stream, section_type, level,
@@ -1265,12 +1263,9 @@ c_type_print_base (struct type *type, struct ui_file *stream,
}
if (TYPE_FN_FIELD_STUB (f, j))
{
- char *tem;
-
/* Build something we can demangle. */
- tem = gdb_mangle_name (type, i, j);
- make_cleanup (xfree, tem);
- mangled_name = tem;
+ mangled_name_holder.reset (gdb_mangle_name (type, i, j));
+ mangled_name = mangled_name_holder.get ();
}
else
mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
@@ -1328,8 +1323,6 @@ c_type_print_base (struct type *type, struct ui_file *stream,
xfree (demangled_name);
}
- do_cleanups (inner_cleanup);
-
fprintf_filtered (stream, ";\n");
}
}