]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Change gdb_realpath_keepfile to return a unique_xmalloc_ptr
authorTom Tromey <tom@tromey.com>
Thu, 3 Aug 2017 22:34:56 +0000 (16:34 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 22 Aug 2017 15:30:11 +0000 (09:30 -0600)
This changes gdb_realpath_keepfile to return a unique_xmalloc_ptr, and
fixes up the callers.

ChangeLog
2017-08-22  Tom Tromey  <tom@tromey.com>

* utils.c (gdb_realpath_keepfile): Return a
gdb::unique_xmalloc_ptr.
* exec.c (exec_file_attach): Update.
* utils.h (gdb_realpath_keepfile): Return a
gdb::unique_xmalloc_ptr.

gdb/ChangeLog
gdb/exec.c
gdb/utils.c
gdb/utils.h

index bb49bc8c16aa3617fcc4be7b3d363b959765691f..8a2bf88c764cbacbdfdf8234af4aee2a3e07dfff 100644 (file)
@@ -1,3 +1,11 @@
+2017-08-22  Tom Tromey  <tom@tromey.com>
+
+       * utils.c (gdb_realpath_keepfile): Return a
+       gdb::unique_xmalloc_ptr.
+       * exec.c (exec_file_attach): Update.
+       * utils.h (gdb_realpath_keepfile): Return a
+       gdb::unique_xmalloc_ptr.
+
 2017-08-22  Tom Tromey  <tom@tromey.com>
 
        * compile/compile.c (compile_file_command): Use
index 6980b07f69abc7118021a33828bb85d424e534d1..45bc133919557f62f8dcbcc4e3bd717219303e4d 100644 (file)
@@ -352,7 +352,7 @@ exec_file_attach (const char *filename, int from_tty)
       if (load_via_target)
        exec_filename = xstrdup (bfd_get_filename (exec_bfd));
       else
-       exec_filename = gdb_realpath_keepfile (scratch_pathname);
+       exec_filename = gdb_realpath_keepfile (scratch_pathname).release ();
 
       if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
        {
index 9959c01af1097773ae14105c4b525dff24c0b84e..5bdc63892362c71f8ab77c53ec37ba2e31ed2a88 100644 (file)
@@ -2716,7 +2716,7 @@ gdb_realpath (const char *filename)
 /* Return a copy of FILENAME, with its directory prefix canonicalized
    by gdb_realpath.  */
 
-char *
+gdb::unique_xmalloc_ptr<char>
 gdb_realpath_keepfile (const char *filename)
 {
   const char *base_name = lbasename (filename);
@@ -2727,7 +2727,7 @@ gdb_realpath_keepfile (const char *filename)
   /* Extract the basename of filename, and return immediately 
      a copy of filename if it does not contain any directory prefix.  */
   if (base_name == filename)
-    return xstrdup (filename);
+    return gdb::unique_xmalloc_ptr<char> (xstrdup (filename));
 
   dir_name = (char *) alloca ((size_t) (base_name - filename + 2));
   /* Allocate enough space to store the dir_name + plus one extra
@@ -2756,7 +2756,7 @@ gdb_realpath_keepfile (const char *filename)
     result = concat (real_path, SLASH_STRING, base_name, (char *) NULL);
 
   xfree (real_path);
-  return result;
+  return gdb::unique_xmalloc_ptr<char> (result);
 }
 
 /* Return PATH in absolute form, performing tilde-expansion if necessary.
index a2a959f13671263670cffd133d45391bc651dc7e..477257bcd9980ab940b7f6fb263ba5586dfdc610 100644 (file)
@@ -254,7 +254,7 @@ extern struct cleanup *make_bpstat_clear_actions_cleanup (void);
 
 extern char *gdb_realpath (const char *);
 
-extern char *gdb_realpath_keepfile (const char *);
+extern gdb::unique_xmalloc_ptr<char> gdb_realpath_keepfile (const char *);
 
 extern gdb::unique_xmalloc_ptr<char> gdb_abspath (const char *);