* [PATCH] Remove an xfree from add_path
@ 2021-12-07 4:42 Tom Tromey
2021-12-07 21:28 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2021-12-07 4:42 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This removes a temporary \0 assignment and an xfree from add_path,
replacing it with a simpler use of std::string.
---
gdb/source.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/gdb/source.c b/gdb/source.c
index 3810af83042..d91389e28b7 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -660,15 +660,10 @@ add_path (const char *dirname, char **which_path, int parse_separators)
more. */
if (prefix)
{
- char *temp, c;
-
- c = old[prefix];
- old[prefix] = '\0';
- temp = concat (old, tinybuf, name, (char *)NULL);
- old[prefix] = c;
- *which_path = concat (temp, "", &old[prefix], (char *) NULL);
- prefix = strlen (temp);
- xfree (temp);
+ std::string temp (old, prefix);
+ *which_path = concat (temp.c_str (), tinybuf, name, &old[prefix],
+ (char *) nullptr);
+ prefix = temp.length ();
}
else
{
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Remove an xfree from add_path
2021-12-07 4:42 [PATCH] Remove an xfree from add_path Tom Tromey
@ 2021-12-07 21:28 ` Tom Tromey
2021-12-08 2:49 ` Simon Marchi
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2021-12-07 21:28 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> This removes a temporary \0 assignment and an xfree from add_path,
Tom> replacing it with a simpler use of std::string.
Oops, I was planning to push a different patch and pushed this one by
mistake. Since it's pretty obvious, I plan to just leave it unless
someone has an objection.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Remove an xfree from add_path
2021-12-07 21:28 ` Tom Tromey
@ 2021-12-08 2:49 ` Simon Marchi
2021-12-08 4:53 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2021-12-08 2:49 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 2021-12-07 16:28, Tom Tromey wrote:
>>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
>
> Tom> This removes a temporary \0 assignment and an xfree from add_path,
> Tom> replacing it with a simpler use of std::string.
>
> Oops, I was planning to push a different patch and pushed this one by
> mistake. Since it's pretty obvious, I plan to just leave it unless
> someone has an objection.
>
> Tom
>
The test gdb.base/source-dir.exp started to fail here following this patch.
Let me know if you can't reproduce.
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Remove an xfree from add_path
2021-12-08 2:49 ` Simon Marchi
@ 2021-12-08 4:53 ` Tom Tromey
2021-12-08 12:22 ` Simon Marchi
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2021-12-08 4:53 UTC (permalink / raw)
To: Simon Marchi; +Cc: Tom Tromey, gdb-patches
Simon> The test gdb.base/source-dir.exp started to fail here following this patch.
Simon> Let me know if you can't reproduce.
Ugh, sorry. I think I must have "harmlessly" tweaked the patch after
testing.
I'm checking in this fix. I made a baseline by running make check
before the earlier patch, then applied this and retested.
Tom
commit 5fdb09a2fd55d4bcf227099b93c1906588399f02
Author: Tom Tromey <tom@tromey.com>
Date: Tue Dec 7 21:51:03 2021 -0700
Fix bug in source.c change
My earlier change to source.c ("Remove an xfree from add_path")
introduced a regression. This patch fixes the problem.
diff --git a/gdb/source.c b/gdb/source.c
index d91389e28b7..f28c30628e6 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -660,8 +660,8 @@ add_path (const char *dirname, char **which_path, int parse_separators)
more. */
if (prefix)
{
- std::string temp (old, prefix);
- *which_path = concat (temp.c_str (), tinybuf, name, &old[prefix],
+ std::string temp = std::string (old, prefix) + tinybuf + name;
+ *which_path = concat (temp.c_str (), &old[prefix],
(char *) nullptr);
prefix = temp.length ();
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Remove an xfree from add_path
2021-12-08 4:53 ` Tom Tromey
@ 2021-12-08 12:22 ` Simon Marchi
0 siblings, 0 replies; 5+ messages in thread
From: Simon Marchi @ 2021-12-08 12:22 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 2021-12-07 23:53, Tom Tromey wrote:
> Simon> The test gdb.base/source-dir.exp started to fail here following this patch.
> Simon> Let me know if you can't reproduce.
>
> Ugh, sorry. I think I must have "harmlessly" tweaked the patch after
> testing.
>
> I'm checking in this fix. I made a baseline by running make check
> before the earlier patch, then applied this and retested.
>
> Tom
Thanks, it's all good now.
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-12-08 12:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 4:42 [PATCH] Remove an xfree from add_path Tom Tromey
2021-12-07 21:28 ` Tom Tromey
2021-12-08 2:49 ` Simon Marchi
2021-12-08 4:53 ` Tom Tromey
2021-12-08 12:22 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).