]> git.ozlabs.org Git - ppp.git/blobdiff - common/zlib.c
pppd: Add master_detach option
[ppp.git] / common / zlib.c
index f806eb8974bca5c7132df12b3232aceb1160cf5f..58c7939cafc3936fd5287084175b7f9b1ddd331a 100644 (file)
  * - added inflateIncomp and deflateOutputPending
  * - allow strm->next_out to be NULL, meaning discard the output
  *
- * $Id: zlib.c,v 1.8 1997/11/27 06:03:32 paulus Exp $
+ * $Id: zlib.c,v 1.12 2002/04/02 13:34:03 dfs Exp $
  */
 
 /* 
- *  ==FILEVERSION 971127==
+ *  ==FILEVERSION 971210==
  *
  * This marker is used by the Linux installation script to determine
  * whether an up-to-date version of this file is already installed.
@@ -52,6 +52,7 @@
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/systm.h>
+#undef u
 #  define HAVE_MEMCPY
 #  define memcpy(d, s, n)      bcopy((s), (d), (n))
 #  define memset(d, v, n)      bzero((d), (n))
@@ -954,7 +955,7 @@ local void flush_pending(strm)
     if (len > strm->avail_out) len = strm->avail_out;
     if (len == 0) return;
 
-    if (strm->next_out != NULL) {
+    if (strm->next_out != Z_NULL) {
        zmemcpy(strm->next_out, s->pending_out, len);
        strm->next_out += len;
     }
@@ -1147,12 +1148,12 @@ int deflateCopy (dest, source)
         return Z_STREAM_ERROR;
     ss = (deflate_state *) source->state;
 
-    *dest = *source;
+    zmemcpy(dest, source, sizeof(*dest));
 
     ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
     if (ds == Z_NULL) return Z_MEM_ERROR;
     dest->state = (struct internal_state FAR *) ds;
-    *ds = *ss;
+    zmemcpy(ds, ss, sizeof(*ds));
     ds->strm = dest;
 
     ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
@@ -3860,10 +3861,11 @@ int r;
                              &s->sub.trees.tb, z);
       if (t != Z_OK)
       {
-        ZFREE(z, s->sub.trees.blens);
         r = t;
-        if (r == Z_DATA_ERROR)
+        if (r == Z_DATA_ERROR) {
           s->mode = BADB;
+          ZFREE(z, s->sub.trees.blens);
+        }
         LEAVE
       }
       s->sub.trees.index = 0;
@@ -3928,14 +3930,16 @@ int r;
 #endif
         t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
                                   s->sub.trees.blens, &bl, &bd, &tl, &td, z);
-        ZFREE(z, s->sub.trees.blens);
         if (t != Z_OK)
         {
-          if (t == (uInt)Z_DATA_ERROR)
+          if (t == (uInt)Z_DATA_ERROR) {
             s->mode = BADB;
+            ZFREE(z, s->sub.trees.blens);
+          }
           r = t;
           LEAVE
         }
+        ZFREE(z, s->sub.trees.blens);
         Tracev((stderr, "inflate:       trees ok, %d * %d bytes used\n",
               inflate_hufts, sizeof(inflate_huft)));
         if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
@@ -4888,7 +4892,7 @@ int r;
     z->adler = s->check = (*s->checkfn)(s->check, q, n);
 
   /* copy as far as end of window */
-  if (p != NULL) {
+  if (p != Z_NULL) {
     zmemcpy(p, q, n);
     p += n;
   }
@@ -4916,7 +4920,7 @@ int r;
       z->adler = s->check = (*s->checkfn)(s->check, q, n);
 
     /* copy */
-    if (p != NULL) {
+    if (p != Z_NULL) {
       zmemcpy(p, q, n);
       p += n;
     }