From 19761b8506f15d6eeeb6ccfab33a11abce0f40e7 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Thu, 29 Dec 2011 00:15:44 -0800 Subject: [PATCH] Permit Z_NULL arguments to deflatePending. This avoids having to create useless variables for return values that aren't needed. --- deflate.c | 6 ++++-- zlib.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/deflate.c b/deflate.c index 159e665..eed6ed8 100644 --- 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 --- 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.