From e011d8c164402cbb1baf92533dfb4f933ec08fee Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Mon, 1 Jul 2024 19:24:01 -0500 Subject: Add deflateUsed() function to get the used bits in the last byte. This returns the number of used bits in the last byte of a stream that has just been compressed with deflate. --- deflate.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'deflate.c') diff --git a/deflate.c b/deflate.c index cbdd880..0c9aa6d 100644 --- a/deflate.c +++ b/deflate.c @@ -719,6 +719,14 @@ int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) { return Z_OK; } +/* ========================================================================= */ +int ZEXPORT deflateUsed(z_streamp strm, int *bits) { + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; + if (bits != Z_NULL) + *bits = strm->state->bi_used; + return Z_OK; +} + /* ========================================================================= */ int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { deflate_state *s; -- cgit v1.2.3-55-g6feb