This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] nscd: Deallocate existing user names in file parser
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: DJ Delorie <dj at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 13 Aug 2018 22:46:01 +0200
- Subject: Re: [PATCH] nscd: Deallocate existing user names in file parser
- References: <xnk1ouhv8j.fsf@greed.delorie.com>
* DJ Delorie:
> Florian Weimer <fw@deneb.enyo.de> writes:
>>> Note that free() nominally takes a void*, not a char*. I think we
>>> should use void* in this case.
>>
>> My idea was to make clear that I'm casting away const here (similar to
>> C++'s const_cast).
>
> Two comments then:
>
> 1. A suitable comment would have make it clearer :-)
I thought this was a standard pattern. 8-)
> 2. Why are those variables const in the first place? They're only ever
> assigned values from xstrdup(), which isn't const.
Presumably to make clear that no in-place modification is expected. I
could drop the const from the pointers, then the cast won't be needed
anymore.