From: Hans Kristian Rosbach Date: Sun, 26 Apr 2015 11:57:22 +0000 (+0200) Subject: Use memcpy, memcmp and memzero directly X-Git-Tag: 1.9.9-b1~880 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3d87960d9fe80d358f760fcebaa948952eba88c;p=thirdparty%2Fzlib-ng.git Use memcpy, memcmp and memzero directly --- diff --git a/arch/x86/fill_window_sse.c b/arch/x86/fill_window_sse.c index d2cd32c7b..a244455c5 100644 --- a/arch/x86/fill_window_sse.c +++ b/arch/x86/fill_window_sse.c @@ -47,7 +47,7 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) */ if (s->strstart >= wsize+MAX_DIST(s)) { - zmemcpy(s->window, s->window+wsize, (unsigned)wsize); + memcpy(s->window, s->window+wsize, (unsigned)wsize); s->match_start -= wsize; s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ s->block_start -= (long) wsize; @@ -148,7 +148,7 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) init = s->window_size - curr; if (init > WIN_INIT) init = WIN_INIT; - zmemzero(s->window + curr, (unsigned)init); + memzero(s->window + curr, 0, (unsigned)init); s->high_water = curr + init; } else if (s->high_water < (ulg)curr + WIN_INIT) { @@ -159,7 +159,7 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) init = (ulg)curr + WIN_INIT - s->high_water; if (init > s->window_size - s->high_water) init = s->window_size - s->high_water; - zmemzero(s->window + s->high_water, (unsigned)init); + memzero(s->window + s->high_water, 0, (unsigned)init); s->high_water += init; } } diff --git a/crc32.c b/crc32.c index 13107fa9a..8e22c69e8 100644 --- a/crc32.c +++ b/crc32.c @@ -461,7 +461,7 @@ ZLIB_INTERNAL void copy_with_crc(z_streamp strm, Byte *dst, long size) return; } #endif - zmemcpy(dst, strm->next_in, size); + memcpy(dst, strm->next_in, size); strm->adler = crc32(strm->adler, dst, size); } diff --git a/deflate.c b/deflate.c index 32d64a4cf..855a3d063 100644 --- a/deflate.c +++ b/deflate.c @@ -228,7 +228,7 @@ bulk_insert_str(deflate_state *s, Pos startpos, uInt count) { */ #define CLEAR_HASH(s) \ s->head[s->hash_size-1] = NIL; \ - zmemzero((Byte *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + memzero((Byte *)s->head, 0, (unsigned)(s->hash_size-1)*sizeof(*s->head)); /* ========================================================================= */ int ZEXPORT deflateInit_(strm, level, version, stream_size) @@ -692,7 +692,7 @@ ZLIB_INTERNAL void flush_pending(strm) if (len > strm->avail_out) len = strm->avail_out; if (len == 0) return; - zmemcpy(strm->next_out, s->pending_out, len); + memcpy(strm->next_out, s->pending_out, len); strm->next_out += len; s->pending_out += len; strm->total_out += len; @@ -1074,12 +1074,12 @@ int ZEXPORT deflateCopy (dest, source) ss = source->state; - zmemcpy((voidp)dest, (voidp)source, sizeof(z_stream)); + memcpy((voidp)dest, (voidp)source, sizeof(z_stream)); ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); if (ds == Z_NULL) return Z_MEM_ERROR; dest->state = (struct internal_state *) ds; - zmemcpy((voidp)ds, (voidp)ss, sizeof(deflate_state)); + memcpy((voidp)ds, (voidp)ss, sizeof(deflate_state)); ds->strm = dest; ds->window = (Byte *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); @@ -1094,10 +1094,10 @@ int ZEXPORT deflateCopy (dest, source) return Z_MEM_ERROR; } - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); - zmemcpy((voidp)ds->prev, (voidp)ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy((voidp)ds->head, (voidp)ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + memcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); + memcpy((voidp)ds->prev, (voidp)ss->prev, ds->w_size * sizeof(Pos)); + memcpy((voidp)ds->head, (voidp)ss->head, ds->hash_size * sizeof(Pos)); + memcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); @@ -1132,7 +1132,7 @@ ZLIB_INTERNAL int read_buf(z_streamp strm, Byte *buf, unsigned size) else #endif { - zmemcpy(buf, strm->next_in, len); + memcpy(buf, strm->next_in, len); if (strm->state->wrap == 1) strm->adler = adler32(strm->adler, buf, len); } @@ -1174,7 +1174,7 @@ local void lm_init (deflate_state *s) local void check_match(deflate_state *s, IPos start, IPos match, int length) { /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, + if (memcmp(s->window + match, s->window + start, length) != EQUAL) { fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); @@ -1240,7 +1240,7 @@ local void fill_window_c(deflate_state *s) */ if (s->strstart >= wsize+MAX_DIST(s)) { - zmemcpy(s->window, s->window+wsize, (unsigned)wsize); + memcpy(s->window, s->window+wsize, (unsigned)wsize); s->match_start -= wsize; s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ s->block_start -= (long) wsize; @@ -1364,7 +1364,7 @@ local void fill_window_c(deflate_state *s) init = s->window_size - curr; if (init > WIN_INIT) init = WIN_INIT; - zmemzero(s->window + curr, (unsigned)init); + memzero(s->window + curr, 0, (unsigned)init); s->high_water = curr + init; } else if (s->high_water < (ulg)curr + WIN_INIT) { @@ -1375,7 +1375,7 @@ local void fill_window_c(deflate_state *s) init = (ulg)curr + WIN_INIT - s->high_water; if (init > s->window_size - s->high_water) init = s->window_size - s->high_water; - zmemzero(s->window + s->high_water, (unsigned)init); + memzero(s->window + s->high_water, 0, (unsigned)init); s->high_water += init; } } diff --git a/infback.c b/infback.c index fdafc0a02..f723fb755 100644 --- a/infback.c +++ b/infback.c @@ -343,7 +343,7 @@ void *out_desc; ROOM(); if (copy > have) copy = have; if (copy > left) copy = left; - zmemcpy(put, next, copy); + memcpy(put, next, copy); have -= copy; next += copy; left -= copy; diff --git a/inflate.c b/inflate.c index bc64251d9..d683760d0 100644 --- a/inflate.c +++ b/inflate.c @@ -397,17 +397,17 @@ local int updatewindow(z_streamp strm, const Byte *end, unsigned copy) /* copy state->wsize or less output bytes into the circular window */ if (copy >= state->wsize) { - zmemcpy(state->window, end - state->wsize, state->wsize); + memcpy(state->window, end - state->wsize, state->wsize); state->wnext = 0; state->whave = state->wsize; } else { dist = state->wsize - state->wnext; if (dist > copy) dist = copy; - zmemcpy(state->window + state->wnext, end - copy, dist); + memcpy(state->window + state->wnext, end - copy, dist); copy -= dist; if (copy) { - zmemcpy(state->window, end - copy, copy); + memcpy(state->window, end - copy, copy); state->wnext = copy; state->whave = state->wsize; } @@ -732,7 +732,7 @@ int flush; if (state->head != Z_NULL && state->head->extra != Z_NULL) { len = state->head->extra_len - state->length; - zmemcpy(state->head->extra + len, next, + memcpy(state->head->extra + len, next, len + copy > state->head->extra_max ? state->head->extra_max - len : copy); } @@ -877,7 +877,7 @@ int flush; if (copy > have) copy = have; if (copy > left) copy = left; if (copy == 0) goto inf_leave; - zmemcpy(put, next, copy); + memcpy(put, next, copy); have -= copy; next += copy; left -= copy; @@ -1272,9 +1272,9 @@ uInt *dictLength; /* copy dictionary */ if (state->whave && dictionary != Z_NULL) { - zmemcpy(dictionary, state->window + state->wnext, + memcpy(dictionary, state->window + state->wnext, state->whave - state->wnext); - zmemcpy(dictionary + state->whave - state->wnext, + memcpy(dictionary + state->whave - state->wnext, state->window, state->wnext); } if (dictLength != Z_NULL) @@ -1456,8 +1456,8 @@ z_streamp source; } /* copy state */ - zmemcpy((voidp)dest, (voidp)source, sizeof(z_stream)); - zmemcpy((voidp)copy, (voidp)state, sizeof(struct inflate_state)); + memcpy((voidp)dest, (voidp)source, sizeof(z_stream)); + memcpy((voidp)copy, (voidp)state, sizeof(struct inflate_state)); if (state->lencode >= state->codes && state->lencode <= state->codes + ENOUGH - 1) { copy->lencode = copy->codes + (state->lencode - state->codes); @@ -1466,7 +1466,7 @@ z_streamp source; copy->next = copy->codes + (state->next - state->codes); if (window != Z_NULL) { wsize = 1U << state->wbits; - zmemcpy(window, state->window, wsize); + memcpy(window, state->window, wsize); } copy->window = window; dest->state = (struct internal_state *)copy; diff --git a/zutil.h b/zutil.h index 6ec9155a0..18398ee45 100644 --- a/zutil.h +++ b/zutil.h @@ -112,10 +112,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* functions */ -#define zmemcpy memcpy -#define zmemcmp memcmp -#define zmemzero(dest, len) memset(dest, 0, len) - /* Diagnostic functions */ #ifdef DEBUG # include