Re: const correctness - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: const correctness
Date
Msg-id 4EBBD85C0200002500042CEE@gw.wicourts.gov
Whole thread Raw
In response to Re: const correctness  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: const correctness
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> wrote:
> On ons, 2011-11-09 at 10:49 -0500, Tom Lane wrote:
>> Now admittedly you can hack it, in the same
>> spirit as the C library functions that are declared to take const
>> pointers and return non-const pointers to the very same data 
> 
> Which C library functions do that?
Tom mentioned the strchr() function, which does do that.  I don't
actually find that surprising given my understanding of the
semantics.  That means that the function is promising not to modify
the character array, but is not asserting that it knows the
character array to be immutable.  Makes sense to me.  It's up to the
caller to assign it to a "const char *" if it knows it passed in an
immutable object.
-Kevin


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: -Wcast-qual cleanup, part 1
Next
From: Bruce Momjian
Date:
Subject: Re: foreign key locks, 2nd attempt