This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 3/3] Make extract_arg return a std::string
>>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes:
>> Change extract_arg to return a std::string and fix up all the users.
>> I think string is mildly better than unique_xmalloc_ptr<char>, when
>> possible, because it provides a more robust API.
Simon> I agree, for strings we allocate dynamically ourselves, it makes sense
Simon> to use std::string. For dynamically allocated strings coming from
Simon> external APIs we use, then unique_xmalloc_ptr<char> make sense, since
Simon> it doesn't require doing a copy. For things that are always
Simon> constant/literal strings, the const char *.
That's my thinking exactly.
It would be nice if string could adopt a unique_xmalloc_ptr. or we
could make string-returning variants of a few functions like
tilde_expand. On the callee side we could move to string_view in the
future.
Simon> It's a bit funny to refer to extract_arg when this function is also
Simon> named extract_arg. What about: "A const-correct version of the
Simon> above." ?
I've made this change in patch #1.
I made the other changes in this patch.
Tom