From: Tom Tromey Date: Thu, 3 Aug 2017 22:34:56 +0000 (-0600) Subject: Change gdb_realpath_keepfile to return a unique_xmalloc_ptr X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4971c9a74b47103582834e46d0185390379e60b3;p=binutils-gdb.git Change gdb_realpath_keepfile to return a unique_xmalloc_ptr This changes gdb_realpath_keepfile to return a unique_xmalloc_ptr, and fixes up the callers. ChangeLog 2017-08-22 Tom Tromey * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bb49bc8c16a..8a2bf88c764 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2017-08-22 Tom Tromey + + * 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 * compile/compile.c (compile_file_command): Use diff --git a/gdb/exec.c b/gdb/exec.c index 6980b07f69a..45bc1339195 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -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)) { diff --git a/gdb/utils.c b/gdb/utils.c index 9959c01af10..5bdc6389236 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -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 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 (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 (result); } /* Return PATH in absolute form, performing tilde-expansion if necessary. diff --git a/gdb/utils.h b/gdb/utils.h index a2a959f1367..477257bcd99 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -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 gdb_realpath_keepfile (const char *); extern gdb::unique_xmalloc_ptr gdb_abspath (const char *);