From: Simon Marchi <simon.marchi@polymtl.ca>
To: Andreas Schwab <schwab@linux-m68k.org>,
Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb: make gdbpy_parse_command_name return a unique_xmalloc_ptr
Date: Tue, 23 Mar 2021 14:21:57 -0400 [thread overview]
Message-ID: <ffd1abc9-7d9f-fb9e-f7d6-9b003675086f@polymtl.ca> (raw)
In-Reply-To: <7b88c9bd-f959-d4a7-4b29-91b46a9f05d8@polymtl.ca>
On 2021-03-23 2:11 p.m., Simon Marchi via Gdb-patches wrote:
> On 2021-03-23 2:07 p.m., Andreas Schwab wrote:> On Mär 23 2021, Simon Marchi via Gdb-patches wrote:
>>
>>> @@ -545,14 +540,19 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
>>> /* If we have our own "invoke" method, then allow unknown
>>> sub-commands. */
>>> allow_unknown = PyObject_HasAttr (self, invoke_cst);
>>> - cmd = add_prefix_cmd (cmd_name, (enum command_class) cmdtype,
>>> + cmd = add_prefix_cmd (cmd_name.get (),
>>> + (enum command_class) cmdtype,
>>> NULL, docstring, &obj->sub_list,
>>> pfx_name, allow_unknown, cmd_list);
>>> }
>>> else
>>> - cmd = add_cmd (cmd_name, (enum command_class) cmdtype,
>>> + cmd = add_cmd (cmd_name.get (), (enum command_class) cmdtype,
>>> docstring, cmd_list);
>>>
>>> + /* The above doesn't copy nor take ownership of the name... so we just
>>> + leak it. */
>>
>> s/leak/release/?
>
> I really wanted to say "leak", as we release it without an owner and
> accept it will never be freed. Sometimes we release in order to
> transfer ownership to the callee (who hasn't been updated to use unique
> pointers yet), but that's not the case here. I think the comment would
> be clear with either word.
Ah, I think I'm mistaken, the Python code uses:
cmd->name_allocated = 1;
Which means the cmd_list_element would free the name if it ever gets
deleted.
I'll change the comment to:
/* If successful, the above takes ownership of the name, since we set
name_allocated, so release it. */
cmd_name.release ();
However, name_allocated isn't set in py-param.c, I guess it should...
Simon
next prev parent reply other threads:[~2021-03-23 18:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-23 17:55 Simon Marchi
2021-03-23 18:07 ` Andreas Schwab
2021-03-23 18:11 ` Simon Marchi
2021-03-23 18:21 ` Simon Marchi [this message]
2021-04-01 17:54 ` Tom Tromey
2021-03-23 18:38 ` [PATCH v2] " Simon Marchi
2021-04-01 17:56 ` Tom Tromey
2021-05-12 17:29 ` Simon Marchi
2021-05-12 14:12 ` Marco Barisione
2021-05-12 14:18 ` Simon Marchi
2021-05-12 17:51 ` [pushed] " Simon Marchi
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=ffd1abc9-7d9f-fb9e-f7d6-9b003675086f@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=schwab@linux-m68k.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).