This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Use unique_xmalloc_ptr in Python code
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Wed, 9 Nov 2016 23:20:33 +0000
- Subject: Re: [RFA] Use unique_xmalloc_ptr in Python code
- Authentication-results: sourceware.org; auth=none
- References: <1478292124-26362-1-git-send-email-tom@tromey.com>
On 11/04/2016 08:42 PM, Tom Tromey wrote:
> This changes some utility functions in the Python code to return
> unique_xmalloc_ptr, and then fixes up the callers.
>
> I chose unique_xmalloc_ptr rather than std::string because at a few
> call points the xmalloc'd string is released and ownership transferred
> elsewhere.
IMO, for simplicity sake, we should default to use std::string, unless
we're ending up storing the result in some long lived objects where
memory really is a concern (because of many instances), and a final
string dup/copy to destination wouldn't be too heavy too. I doubt
that's the case here, but it's not easy to see without trying.
Did you try a std::string approach first?
In any case, this is strictly an improvement, so OK with me. Please
push. Let's get this out of the way of your py-ref series.
We can convert to std::string at some other point, if desirable.
Thanks,
Pedro Alves