From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 2/5] Change gdb_realpath_keepfile to return a unique_xmalloc_ptr
Date: Fri, 18 Aug 2017 20:01:00 -0000 [thread overview]
Message-ID: <20170818200024.4948-3-tom@tromey.com> (raw)
In-Reply-To: <20170818200024.4948-1-tom@tromey.com>
This changes gdb_realpath_keepfile to return a unique_xmalloc_ptr, and
fixes up the callers.
ChangeLog
2017-08-18 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 | 8 ++++++++
gdb/exec.c | 2 +-
gdb/utils.c | 6 +++---
gdb/utils.h | 2 +-
4 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e75d1b7..ec022c3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2017-08-18 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-18 Tom Tromey <tom@tromey.com>
+
* compile/compile.c (compile_file_command): Use
gdb::unique_xmalloc_ptr, std::string.
* utils.c (gdb_abspath): Change return type.
diff --git a/gdb/exec.c b/gdb/exec.c
index 6980b07..45bc133 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 9959c01..5bdc638 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<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.
diff --git a/gdb/utils.h b/gdb/utils.h
index a2a959f..477257b 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<char> gdb_realpath_keepfile (const char *);
extern gdb::unique_xmalloc_ptr<char> gdb_abspath (const char *);
--
2.9.4
next prev parent reply other threads:[~2017-08-18 20:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-18 20:01 [RFA 0/5] simple string changes Tom Tromey
2017-08-18 20:01 ` [RFA 4/5] Change rewrite_source_path to return a unique_xmalloc_ptr Tom Tromey
2017-08-18 20:01 ` [RFA 3/5] Change gdb_realpath " Tom Tromey
2017-08-18 20:01 ` Tom Tromey [this message]
2017-08-18 20:01 ` [RFA 5/5] Change psymtab_search_name " Tom Tromey
2017-08-18 20:01 ` [RFA 1/5] Change gdb_abspath " Tom Tromey
2017-08-21 9:57 ` [RFA 0/5] simple string changes Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170818200024.4948-3-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox