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: [PATCH] Convert 'name' of 'struct varobj' to 'const char *'.


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.
Tom,
What do you mean by "really const"?  We allocate a string for the name
of var, use type "const char *", which means we can't modify the
contents.  In the end, we xfree (var->name) as a step to release var.
We need a cast because we'll get a warning otherwise,

../../../git/gdb/varobj.c:2531:3: error: passing argument 1 of âxfreeâ discards âconstâ qualifier from pointer target type [-Werror] ../../../git/gdb/common/common-utils.h:38:6: note: expected âvoid *â but argument is of type âconst char *â

Am I missing something?

--
Yao (éå)


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