This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Use unique_xmalloc_ptr in Python code


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]