+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
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))
{
/* 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);
/* 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
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.
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 *);