This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Convert 'name' of 'struct varobj' to 'const char *'.
- From: Tom Tromey <tromey at redhat dot com>
- To: Yao Qi <yao at codesourcery dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Mon, 09 Sep 2013 12:02:13 -0600
- Subject: Re: [PATCH] Convert 'name' of 'struct varobj' to 'const char *'.
- Authentication-results: sourceware.org; auth=none
- References: <1377825178-20943-1-git-send-email-yao at codesourcery dot com> <8738prno9z dot fsf at fleche dot redhat dot com> <52214567 dot 2020009 at codesourcery dot com>
>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:
Yao> On 08/31/2013 12:20 AM, Tom Tromey wrote:
Yao> - xfree (var->name);
Yao> + xfree ((void *) var->name);
>>
>> But here we cast away const to free the object.
>>
>> I think this means the object wasn't "really const". It's an
>> abstraction violation.
Yao> What do you mean by "really const"?
What, that isn't defined by the standard? :-)
What I mean is that the code in the patch has a function that accepts a
"const char *", but the caller must know that this actually means that
only malloc'd strings are acceptable and that there is a transfer of
ownership.
I think this is an unusual use of const.
Tom