[PATCH 2/2] gdb: remove xfree in xml-support.c

Simon Marchi simon.marchi@polymtl.ca
Mon Aug 10 19:23:44 GMT 2020


Replace an xfree with automatic memory management with a unique pointer.

gdb/ChangeLog:

	* xml-support.c (xml_fetch_content_from_file): Replace xfree
	with gdb::unique_xmalloc_ptr<char>.

Change-Id: Ia4d735b383e3b9eb660f445f2c7f2c5e27411b64
---
 gdb/xml-support.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 8b698e511f12..5568c8a74ec4 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -969,10 +969,10 @@ xml_fetch_content_from_file (const char *filename, const char *dirname)
 
   if (dirname != nullptr && *dirname != '\0')
     {
-      char *fullname = concat (dirname, "/", filename, (char *) NULL);
+      gdb::unique_xmalloc_ptr<char> fullname
+	(concat (dirname, "/", filename, (char *) NULL));
 
-      file = gdb_fopen_cloexec (fullname, FOPEN_RB);
-      xfree (fullname);
+      file = gdb_fopen_cloexec (fullname.get (), FOPEN_RB);
     }
   else
     file = gdb_fopen_cloexec (filename, FOPEN_RB);
-- 
2.28.0



More information about the Gdb-patches mailing list