diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2011-10-18 23:05:37 -0700 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2011-10-18 23:05:37 -0700 |
| commit | 5ab9f47745fe9353291b217f705086b6070575d5 (patch) | |
| tree | 0a6c69f912f56cdbd36328cc67e4637bde6208b9 | |
| parent | 5b48d061c8c46bc19e6ad965157440880e5708b9 (diff) | |
| download | zlib-5ab9f47745fe9353291b217f705086b6070575d5.tar.gz zlib-5ab9f47745fe9353291b217f705086b6070575d5.tar.bz2 zlib-5ab9f47745fe9353291b217f705086b6070575d5.zip | |
Add #define ZLIB_CONST option to use const in the z_stream interface.
This permits compilers to check for the proper treatment of next_in and
msg in the z_stream structure. This is an option instead of the default
in order to preserve backward compatibility. Some applications make use
of the z_stream structure outside of zlib, and perform operations such
as free(strm->next_in), which would not be permitted when next_in is
const. The #define ZLIB_CONST needs to precede the #include "zlib.h">,
in order to make next_in and msg const pointers in the z_stream type.
| -rw-r--r-- | zconf.h | 6 | ||||
| -rw-r--r-- | zconf.h.cmakein | 6 | ||||
| -rw-r--r-- | zconf.h.in | 6 | ||||
| -rw-r--r-- | zlib.h | 4 |
4 files changed, 20 insertions, 2 deletions
| @@ -214,6 +214,12 @@ | |||
| 214 | # endif | 214 | # endif |
| 215 | #endif | 215 | #endif |
| 216 | 216 | ||
| 217 | #if defined(ZLIB_CONST) && !defined(z_const) | ||
| 218 | # define z_const const | ||
| 219 | #else | ||
| 220 | # define z_const | ||
| 221 | #endif | ||
| 222 | |||
| 217 | /* Some Mac compilers merge all .h files incorrectly: */ | 223 | /* Some Mac compilers merge all .h files incorrectly: */ |
| 218 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) | 224 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) |
| 219 | # define NO_DUMMY_DECL | 225 | # define NO_DUMMY_DECL |
diff --git a/zconf.h.cmakein b/zconf.h.cmakein index 8450547..0b880ad 100644 --- a/zconf.h.cmakein +++ b/zconf.h.cmakein | |||
| @@ -216,6 +216,12 @@ | |||
| 216 | # endif | 216 | # endif |
| 217 | #endif | 217 | #endif |
| 218 | 218 | ||
| 219 | #if defined(ZLIB_CONST) && !defined(z_const) | ||
| 220 | # define z_const const | ||
| 221 | #else | ||
| 222 | # define z_const | ||
| 223 | #endif | ||
| 224 | |||
| 219 | /* Some Mac compilers merge all .h files incorrectly: */ | 225 | /* Some Mac compilers merge all .h files incorrectly: */ |
| 220 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) | 226 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) |
| 221 | # define NO_DUMMY_DECL | 227 | # define NO_DUMMY_DECL |
| @@ -214,6 +214,12 @@ | |||
| 214 | # endif | 214 | # endif |
| 215 | #endif | 215 | #endif |
| 216 | 216 | ||
| 217 | #if defined(ZLIB_CONST) && !defined(z_const) | ||
| 218 | # define z_const const | ||
| 219 | #else | ||
| 220 | # define z_const | ||
| 221 | #endif | ||
| 222 | |||
| 217 | /* Some Mac compilers merge all .h files incorrectly: */ | 223 | /* Some Mac compilers merge all .h files incorrectly: */ |
| 218 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) | 224 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) |
| 219 | # define NO_DUMMY_DECL | 225 | # define NO_DUMMY_DECL |
| @@ -83,7 +83,7 @@ typedef void (*free_func) OF((voidpf opaque, voidpf address)); | |||
| 83 | struct internal_state; | 83 | struct internal_state; |
| 84 | 84 | ||
| 85 | typedef struct z_stream_s { | 85 | typedef struct z_stream_s { |
| 86 | Bytef *next_in; /* next input byte */ | 86 | z_const Bytef *next_in; /* next input byte */ |
| 87 | uInt avail_in; /* number of bytes available at next_in */ | 87 | uInt avail_in; /* number of bytes available at next_in */ |
| 88 | uLong total_in; /* total number of input bytes read so far */ | 88 | uLong total_in; /* total number of input bytes read so far */ |
| 89 | 89 | ||
| @@ -91,7 +91,7 @@ typedef struct z_stream_s { | |||
| 91 | uInt avail_out; /* remaining free space at next_out */ | 91 | uInt avail_out; /* remaining free space at next_out */ |
| 92 | uLong total_out; /* total number of bytes output so far */ | 92 | uLong total_out; /* total number of bytes output so far */ |
| 93 | 93 | ||
| 94 | char *msg; /* last error message, NULL if no error */ | 94 | z_const char *msg; /* last error message, NULL if no error */ |
| 95 | struct internal_state FAR *state; /* not visible by applications */ | 95 | struct internal_state FAR *state; /* not visible by applications */ |
| 96 | 96 | ||
| 97 | alloc_func zalloc; /* used to allocate the internal state */ | 97 | alloc_func zalloc; /* used to allocate the internal state */ |
