Permit Z_NULL arguments to deflatePending.
authorMark Adler <madler@alumni.caltech.edu>
Thu, 29 Dec 2011 08:15:44 +0000 (00:15 -0800)
committerMark Adler <madler@alumni.caltech.edu>
Thu, 29 Dec 2011 08:15:44 +0000 (00:15 -0800)
This avoids having to create useless variables for return values
that aren't needed.

deflate.c
zlib.h

index 159e665..eed6ed8 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -451,8 +451,10 @@ int ZEXPORT deflatePending (strm, pending, bits)
     z_streamp strm;
 {
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-    *pending = strm->state->pending;
-    *bits = strm->state->bi_valid;
+    if (pending != Z_NULL)
+        *pending = strm->state->pending;
+    if (bits != Z_NULL)
+        *bits = strm->state->bi_valid;
     return Z_OK;
 }
 
diff --git a/zlib.h b/zlib.h
index 9ca20d7..20e13db 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -715,7 +715,8 @@ ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
    been generated, but not yet provided in the available output.  The bytes not
    provided would be due to the available output space having being consumed.
    The number of bits of output not provided are between 0 and 7, where they
-   await more bits to join them in order to fill out a full byte.
+   await more bits to join them in order to fill out a full byte.  If pending
+   or bits are Z_NULL, then those values are not set.
 
      deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
    stream state was inconsistent.