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: Yao Qi <yao at codesourcery dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Sat, 31 Aug 2013 09:22:47 +0800
- 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>
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 (éå)