diff options
| -rw-r--r-- | deflate.c | 11 | ||||
| -rw-r--r-- | inflate.c | 4 | ||||
| -rw-r--r-- | zutil.c | 34 | ||||
| -rw-r--r-- | zutil.h | 6 |
4 files changed, 30 insertions, 25 deletions
| @@ -170,8 +170,7 @@ local const config configuration_table[10] = { | |||
| 170 | #define CLEAR_HASH(s) \ | 170 | #define CLEAR_HASH(s) \ |
| 171 | do { \ | 171 | do { \ |
| 172 | s->head[s->hash_size - 1] = NIL; \ | 172 | s->head[s->hash_size - 1] = NIL; \ |
| 173 | zmemzero((Bytef *)s->head, \ | 173 | zmemzero(s->head, (unsigned)(s->hash_size - 1)*sizeof(*s->head)); \ |
| 174 | (unsigned)(s->hash_size - 1)*sizeof(*s->head)); \ | ||
| 175 | s->slid = 0; \ | 174 | s->slid = 0; \ |
| 176 | } while (0) | 175 | } while (0) |
| 177 | 176 | ||
| @@ -1331,13 +1330,13 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { | |||
| 1331 | 1330 | ||
| 1332 | ss = source->state; | 1331 | ss = source->state; |
| 1333 | 1332 | ||
| 1334 | zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); | 1333 | zmemcpy(dest, source, sizeof(z_stream)); |
| 1335 | 1334 | ||
| 1336 | ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); | 1335 | ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); |
| 1337 | if (ds == Z_NULL) return Z_MEM_ERROR; | 1336 | if (ds == Z_NULL) return Z_MEM_ERROR; |
| 1338 | zmemzero(ds, sizeof(deflate_state)); | 1337 | zmemzero(ds, sizeof(deflate_state)); |
| 1339 | dest->state = (struct internal_state FAR *) ds; | 1338 | dest->state = (struct internal_state FAR *) ds; |
| 1340 | zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state)); | 1339 | zmemcpy(ds, ss, sizeof(deflate_state)); |
| 1341 | ds->strm = dest; | 1340 | ds->strm = dest; |
| 1342 | 1341 | ||
| 1343 | ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); | 1342 | ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); |
| @@ -1352,10 +1351,10 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { | |||
| 1352 | } | 1351 | } |
| 1353 | /* following zmemcpy's do not work for 16-bit MSDOS */ | 1352 | /* following zmemcpy's do not work for 16-bit MSDOS */ |
| 1354 | zmemcpy(ds->window, ss->window, ss->high_water); | 1353 | zmemcpy(ds->window, ss->window, ss->high_water); |
| 1355 | zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, | 1354 | zmemcpy(ds->prev, ss->prev, |
| 1356 | (ss->slid || ss->strstart - ss->insert > ds->w_size ? ds->w_size : | 1355 | (ss->slid || ss->strstart - ss->insert > ds->w_size ? ds->w_size : |
| 1357 | ss->strstart - ss->insert) * sizeof(Pos)); | 1356 | ss->strstart - ss->insert) * sizeof(Pos)); |
| 1358 | zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); | 1357 | zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); |
| 1359 | 1358 | ||
| 1360 | ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); | 1359 | ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); |
| 1361 | zmemcpy(ds->pending_out, ss->pending_out, ss->pending); | 1360 | zmemcpy(ds->pending_out, ss->pending_out, ss->pending); |
| @@ -1351,8 +1351,8 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) { | |||
| 1351 | } | 1351 | } |
| 1352 | 1352 | ||
| 1353 | /* copy state */ | 1353 | /* copy state */ |
| 1354 | zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); | 1354 | zmemcpy(dest, source, sizeof(z_stream)); |
| 1355 | zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); | 1355 | zmemcpy(copy, state, sizeof(struct inflate_state)); |
| 1356 | copy->strm = dest; | 1356 | copy->strm = dest; |
| 1357 | if (state->lencode >= state->codes && | 1357 | if (state->lencode >= state->codes && |
| 1358 | state->lencode <= state->codes + ENOUGH - 1) { | 1358 | state->lencode <= state->codes + ENOUGH - 1) { |
| @@ -150,28 +150,34 @@ const char * ZEXPORT zError(int err) { | |||
| 150 | 150 | ||
| 151 | #ifndef HAVE_MEMCPY | 151 | #ifndef HAVE_MEMCPY |
| 152 | 152 | ||
| 153 | void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) { | 153 | void ZLIB_INTERNAL zmemcpy(void FAR *dst, const void FAR *src, z_size_t n) { |
| 154 | if (len == 0) return; | 154 | uchf *p = dst; |
| 155 | do { | 155 | const uchf *q = src; |
| 156 | *dest++ = *source++; /* ??? to be unrolled */ | 156 | while (n) { |
| 157 | } while (--len != 0); | 157 | *p++ = *q++; |
| 158 | n--; | ||
| 159 | } | ||
| 158 | } | 160 | } |
| 159 | 161 | ||
| 160 | int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) { | 162 | int ZLIB_INTERNAL zmemcmp(const void FAR *s1, const void FAR *s2, z_size_t n) { |
| 161 | uInt j; | 163 | const uchf *p = s1, *q = s2; |
| 162 | 164 | while (n) { | |
| 163 | for (j = 0; j < len; j++) { | 165 | if (*p++ != *q++) |
| 164 | if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; | 166 | return (int)p[-1] - (int)q[-1]; |
| 167 | n--; | ||
| 165 | } | 168 | } |
| 166 | return 0; | 169 | return 0; |
| 167 | } | 170 | } |
| 168 | 171 | ||
| 169 | void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) { | 172 | void ZLIB_INTERNAL zmemzero(void FAR *b, z_size_t len) { |
| 173 | uchf *p = b; | ||
| 170 | if (len == 0) return; | 174 | if (len == 0) return; |
| 171 | do { | 175 | while (len) { |
| 172 | *dest++ = 0; /* ??? to be unrolled */ | 176 | *p++ = 0; |
| 173 | } while (--len != 0); | 177 | len--; |
| 178 | } | ||
| 174 | } | 179 | } |
| 180 | |||
| 175 | #endif | 181 | #endif |
| 176 | 182 | ||
| 177 | #ifndef Z_SOLO | 183 | #ifndef Z_SOLO |
| @@ -218,9 +218,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
| 218 | # define zmemzero(dest, len) memset(dest, 0, len) | 218 | # define zmemzero(dest, len) memset(dest, 0, len) |
| 219 | # endif | 219 | # endif |
| 220 | #else | 220 | #else |
| 221 | void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len); | 221 | void ZLIB_INTERNAL zmemcpy(void FAR *, const void FAR *, z_size_t); |
| 222 | int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len); | 222 | int ZLIB_INTERNAL zmemcmp(const void FAR *, const void FAR *, z_size_t); |
| 223 | void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len); | 223 | void ZLIB_INTERNAL zmemzero(void FAR *, z_size_t); |
| 224 | #endif | 224 | #endif |
| 225 | 225 | ||
| 226 | /* Diagnostic functions */ | 226 | /* Diagnostic functions */ |
