[Zlib-devel] Allow read-only data as input

Cosmin Truta cosmin at cs.toronto.edu
Tue Mar 29 08:49:12 EDT 2011


Lasse Collin wrote:
> I agree that it could have been nice to have the const there, but I
> think it is too late to change it. Existing applications already have
> the required casts. Adding the const now would require fixing
> applications that assume that next_in isn't const.

Generally, there should be no need to change any surrounding code if
the lvalue changes from a non-const pointer to a const pointer.

int *p;
int *q;
p = q;

can be changed to

const int *p;
int *q;
p = q;

There should be no issues, neither with source compatibility, nor with
binary compatibility.
In fact, a similar change was done recently in libpng.

If anything does need to be changed, that's the code that reads
z_stream_s.next_in, but that's inside zlib.


Best regards,
Cosmin




More information about the Zlib-devel mailing list