From: Tom Tromey <tom@tromey.com>
To: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Cc: Tom Tromey <tom@tromey.com>, Simon Marchi <simark@simark.ca>,
Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH] gdb: cast return value of std::unique_ptr::release to void
Date: Wed, 15 Feb 2023 10:04:27 -0700 [thread overview]
Message-ID: <87h6vmrhb8.fsf@tromey.com> (raw)
In-Reply-To: <93c37005-30ec-f211-9e06-3a4896e134b2@simark.ca> (Simon Marchi via Gdb-patches's message of "Tue, 14 Feb 2023 14:29:16 -0500")
Simon> I wanted to change cmd_list_element in the past to have "doc_holder" and
Simon> "name_holder" fields, both of which would be
Simon> gdb::unique_xmalloc_ptr<char>. They would be set if the
Simon> cmd_list_element owns the memory for doc and name, and would make the
Simon> management automatic. But I'm afraid that people will say "but it makes
Simon> cmd_list_element larger for nothing", so I never sent it. But if you
Simon> think it's worth it, I can do that.
I am not worried about the space savings here. It doesn't seem so bad
to have a bit of manual management in this code, but at the same time,
it wouldn't be a huge amount of memory, and if it makes things clearer,
then it seems great.
Stove-piping the unique ptr through all this code seems like a pain,
though.
I've sometimes wondered if we want a either-owns-or-is-constant-string
smart pointer type. But it seems maybe hard to make this safe to use,
as in it may be easy to construct one improperly.
Tom
prev parent reply other threads:[~2023-02-15 17:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-13 19:55 Simon Marchi
2023-02-14 0:13 ` Tom Tromey
2023-02-14 19:29 ` Simon Marchi
2023-02-15 17:04 ` Tom Tromey [this message]
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=87h6vmrhb8.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
--cc=simon.marchi@efficios.com \
/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).