]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Use memcpy, memcmp and memzero directly
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Sun, 26 Apr 2015 11:57:22 +0000 (13:57 +0200)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Sun, 26 Apr 2015 11:57:22 +0000 (13:57 +0200)
arch/x86/fill_window_sse.c
crc32.c
deflate.c
infback.c
inflate.c
zutil.h

index d2cd32c7b0c1757de8bbd53a9adecca161bace26..a244455c5297234469035f78cc9efcf1b0a6af1a 100644 (file)
@@ -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 13107fa9a147409f79c439053fd9d34c585ea7b0..8e22c69e879a4408852c0bf6756918cd8f9d88cf 100644 (file)
--- 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);
 }
 
index 32d64a4cfd456dd79d918d3c79de85e953970181..855a3d063b670ae6ad4858089ad72b74e84cd9e7 100644 (file)
--- 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;
         }
     }
index fdafc0a026506af36af5616f114bd4152ca562eb..f723fb755a14c533ca59c0d35807e213a11d2ca0 100644 (file)
--- 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;
index bc64251d9bde59dc08eab38c7278e43fdedf02cf..d683760d07f36eea09faa6ebb2d478245699eb1a 100644 (file)
--- 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 6ec9155a07096b632f21dd0d8775d2ce13a2f64c..18398ee45cd9ae64c44b8b2209dbd1bd65ac1172 100644 (file)
--- 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 <stdio.h>