aboutsummaryrefslogtreecommitdiff
path: root/gdb/xml-tdesc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/xml-tdesc.c')
-rw-r--r--gdb/xml-tdesc.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c
index daa713f..5a1f459 100644
--- a/gdb/xml-tdesc.c
+++ b/gdb/xml-tdesc.c
@@ -673,24 +673,16 @@ tdesc_parse_xml (const char *document, xml_fetch_another fetcher,
const struct target_desc *
file_read_description_xml (const char *filename)
{
- struct target_desc *tdesc;
- char *tdesc_str;
- struct cleanup *back_to;
-
- tdesc_str = xml_fetch_content_from_file (filename, NULL);
+ gdb::unique_xmalloc_ptr<char> tdesc_str
+ = xml_fetch_content_from_file (filename, NULL);
if (tdesc_str == NULL)
{
warning (_("Could not open \"%s\""), filename);
return NULL;
}
- back_to = make_cleanup (xfree, tdesc_str);
-
- tdesc = tdesc_parse_xml (tdesc_str, xml_fetch_content_from_file,
- (void *) ldirname (filename).c_str ());
- do_cleanups (back_to);
-
- return tdesc;
+ return tdesc_parse_xml (tdesc_str.get (), xml_fetch_content_from_file,
+ (void *) ldirname (filename).c_str ());
}
/* Read a string representation of available features from the target,
@@ -700,7 +692,7 @@ file_read_description_xml (const char *filename)
is "target.xml". Other calls may be performed for the DTD or
for <xi:include>. */
-static char *
+static gdb::unique_xmalloc_ptr<char>
fetch_available_features_from_target (const char *name, void *baton_)
{
struct target_ops *ops = (struct target_ops *) baton_;
@@ -719,21 +711,14 @@ fetch_available_features_from_target (const char *name, void *baton_)
const struct target_desc *
target_read_description_xml (struct target_ops *ops)
{
- struct target_desc *tdesc;
- char *tdesc_str;
- struct cleanup *back_to;
-
- tdesc_str = fetch_available_features_from_target ("target.xml", ops);
+ gdb::unique_xmalloc_ptr<char> tdesc_str
+ = fetch_available_features_from_target ("target.xml", ops);
if (tdesc_str == NULL)
return NULL;
- back_to = make_cleanup (xfree, tdesc_str);
- tdesc = tdesc_parse_xml (tdesc_str,
- fetch_available_features_from_target,
- ops);
- do_cleanups (back_to);
-
- return tdesc;
+ return tdesc_parse_xml (tdesc_str.get (),
+ fetch_available_features_from_target,
+ ops);
}
/* Fetches an XML target description using OPS, processing
@@ -758,7 +743,7 @@ target_fetch_description_xml (struct target_ops *ops)
struct target_desc *tdesc;
gdb::unique_xmalloc_ptr<char>
- tdesc_str (fetch_available_features_from_target ("target.xml", ops));
+ tdesc_str = fetch_available_features_from_target ("target.xml", ops);
if (tdesc_str == NULL)
return {};