[PATCH] Convert 'name' of 'struct varobj' to 'const char *'.

Tom Tromey tromey@redhat.com
Mon Sep 9 18:02:00 GMT 2013


>>>>> "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



More information about the Gdb-patches mailing list