[Zlib-devel] Allow read-only data as input
jbowler at acm.org
jbowler at acm.org
Thu Mar 31 01:07:44 EDT 2011
From: zlib-devel-bounces at madler.net [mailto:zlib-devel-bounces at madler.net] On Behalf Of Mike Frysinger
>On Mon, Mar 28, 2011 at 9:29 PM, Mark Adler wrote:
>> What if we added a ZLIB_CONST #define that, if defined, would add the const's in zlib.h where appropriate?
Yes, that helps libpng remove a spurious cast.
>what if we negated the logic so that people would get const by default ?
>so people could define ZLIB_NO_CONST to avoid transitional logic.
Yes, that helps libpng in the same way.
Counter-intuitively neither approach is better. Either requires libpng to check the zlib version number around the cast it makes when it assigns its own read-only buffer to next_in.
As Cosmin points out, making parameters (including members of structs that are parameters) be const when they weren't before is not an API or an ABI issue. Const on a parameter is a commitment, not a requirement, and it can be met by non-const data. It is good, and useful, to add const to as many parameters as possible - libpng has been doing that and it hasn't yet raised any problems.
John Bowler <jbowler at acm.org>
More information about the Zlib-devel
mailing list