[Zlib-devel] Allow read-only data as input
Jonathan Nieder
jrnieder at gmail.com
Mon Mar 28 21:52:59 EDT 2011
Mike Frysinger wrote:
> Mark Adler wrote:
>> What if we added a ZLIB_CONST #define that, if defined, would add the
>> const's in zlib.h where appropriate?
Sounds excellent to me, for what it's worth.
> 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.
That would needlessly cause existing programs that "free(s.next_in);"
to break without warning.
Maybe it makes sense to advertise some method to use today to avoid
breaking programs tomorrow, like so:
| The new ZLIB_CONST macro can be used to add consts in zlib.h where
| appropriate. Please try it out:
|
| #define ZLIB_CONST const
| #include <zlib.h>
|
| and if it causes your program to emit compile-time warnings or
| fail compile, define ZLIB_CONST to be empty before including zlib.h:
|
| #define ZLIB_CONST
| #include <zlib.h>
|
| This way, if the default for ZLIB_CONST changes to const in some
| future zlib version, your program will not be affected.
Though tracking down the required casts (as in "free((Bytef *) p);")
is probably easy enough that it's hard to imagine wanting to ever do
that.
Jonathan
More information about the Zlib-devel
mailing list