diff options
author | Pedro Alves <palves@redhat.com> | 2016-11-08 15:26:46 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-11-08 15:26:46 +0000 |
commit | 3b4de39c9d9ff014ae90e2bafbf7ce1f42c2198e (patch) | |
tree | 699d0e34db94c8e2301e50d93f1ce5338a7f8181 | |
parent | 6f0302493af0ace93943041c3374069c15c363f7 (diff) | |
download | gdb-3b4de39c9d9ff014ae90e2bafbf7ce1f42c2198e.zip gdb-3b4de39c9d9ff014ae90e2bafbf7ce1f42c2198e.tar.gz gdb-3b4de39c9d9ff014ae90e2bafbf7ce1f42c2198e.tar.bz2 |
Use ui_file_as_string in gdb/ada-lang.c
gdb/ChangeLog:
2016-11-08 Pedro Alves <palves@redhat.com>
* ada-lang.c (type_as_string): Use ui_file_as_string and return
std::string.
(type_as_string_and_cleanup): Delete.
(ada_lookup_struct_elt_type): Use type_as_string.
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/ada-lang.c | 31 |
2 files changed, 13 insertions, 25 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cb0e774..bfd58d7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2016-11-08 Pedro Alves <palves@redhat.com> + * ada-lang.c (type_as_string): Use ui_file_as_string and return + std::string. + (type_as_string_and_cleanup): Delete. + (ada_lookup_struct_elt_type): Use type_as_string. + +2016-11-08 Pedro Alves <palves@redhat.com> + * gdbarch.sh (verify_gdbarch): Use ui_file_as_string and std::string. * gdbarch.c: Regenerate. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index d1a39bc..3c04554 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -7608,39 +7608,24 @@ ada_value_struct_elt (struct value *arg, char *name, int no_err) "a value that is not a record.")); } -/* Return a string representation of type TYPE. Caller must free - result. */ +/* Return a string representation of type TYPE. */ -static char * +static std::string type_as_string (struct type *type) { struct ui_file *tmp_stream = mem_fileopen (); struct cleanup *old_chain; - char *str; tmp_stream = mem_fileopen (); old_chain = make_cleanup_ui_file_delete (tmp_stream); type_print (type, "", tmp_stream, -1); - str = ui_file_xstrdup (tmp_stream, NULL); + std::string str = ui_file_as_string (tmp_stream); do_cleanups (old_chain); return str; } -/* Return a string representation of type TYPE, and install a cleanup - that releases it. */ - -static char * -type_as_string_and_cleanup (struct type *type) -{ - char *str; - - str = type_as_string (type); - make_cleanup (xfree, str); - return str; -} - /* Given a type TYPE, look up the type of the component of type named NAME. If DISPP is non-null, add its byte displacement from the beginning of a structure (pointed to by a value) of type TYPE to *DISPP (does not @@ -7681,15 +7666,11 @@ ada_lookup_struct_elt_type (struct type *type, char *name, int refok, || (TYPE_CODE (type) != TYPE_CODE_STRUCT && TYPE_CODE (type) != TYPE_CODE_UNION)) { - const char *type_str; - if (noerr) return NULL; - type_str = (type != NULL - ? type_as_string_and_cleanup (type) - : _("(null)")); - error (_("Type %s is not a structure or union type"), type_str); + error (_("Type %s is not a structure or union type"), + type != NULL ? type_as_string (type).c_str () : _("(null)")); } type = to_static_fixed_type (type); @@ -7762,7 +7743,7 @@ BadName: const char *name_str = name != NULL ? name : _("<null>"); error (_("Type %s has no component named %s"), - type_as_string_and_cleanup (type), name_str); + type_as_string (type).c_str (), name_str); } return NULL; |