]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add inflateCodesUsed() function
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Wed, 1 Feb 2017 10:50:29 +0000 (11:50 +0100)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Wed, 1 Feb 2017 10:50:29 +0000 (11:50 +0100)
Based on upstream commit 5370d99a2affe0b040550cffbc0ba8fa790594b3

inflate.c
zlib.h

index 1f715db568c13c9c85fbab3815e481ba28e56a2e..f0a341501d2f64a1d3d37f6d9577d7091f512359 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -1478,3 +1478,11 @@ long ZEXPORT inflateMark(z_stream *strm) {
     return ((long)(state->back) << 16) + (state->mode == COPY ? state->length :
             (state->mode == MATCH ? state->was - state->length : 0));
 }
+
+unsigned long ZEXPORT inflateCodesUsed(z_stream *strm) {
+    struct inflate_state *state;
+    if (strm == NULL || strm->state == NULL)
+        return (unsigned long)0 - 1;
+    state = (struct inflate_state *)strm->state;
+    return (unsigned long)(state->next - state->codes);
+}
diff --git a/zlib.h b/zlib.h
index 92e84e889b140e5e47fa7a14ca106c6830d5f7b1..91bd18e9ff910d1f55430e0498958ea517b51914 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -1712,6 +1712,7 @@ ZEXTERN int              ZEXPORT inflateSyncPoint (z_stream *);
 ZEXTERN const uint32_t * ZEXPORT get_crc_table    (void);
 ZEXTERN int              ZEXPORT inflateUndermine (z_stream *, int);
 ZEXTERN int              ZEXPORT inflateValidate  (z_stream *, int);
+ZEXTERN unsigned long    ZEXPORT inflateCodesUsed (z_stream *);
 ZEXTERN int              ZEXPORT inflateResetKeep (z_stream *);
 ZEXTERN int              ZEXPORT deflateResetKeep (z_stream *);