summaryrefslogtreecommitdiff
path: root/infback.c
diff options
context:
space:
mode:
authorHans Kristian Rosbach <hk-git@circlestorm.org>2019-07-18 15:49:54 +0200
committerHans Kristian Rosbach <hk-github@circlestorm.org>2019-08-06 09:39:26 +0200
commitd8eedcfa3e391cca6d247ebde2f5c64bd64582d6 (patch)
treeb121c60680118650e865ba963291614e81c5fd41 /infback.c
parentf06c71f9817700eccb507f54249a8c52335bf693 (diff)
Deduplicate common inflate/inflatefast/inflateBack macros into inflate_p.h
Diffstat (limited to 'infback.c')
-rw-r--r--infback.c62
1 files changed, 4 insertions, 58 deletions
diff --git a/infback.c b/infback.c
index 1dfc34b..e3886b5 100644
--- a/infback.c
+++ b/infback.c
@@ -15,6 +15,7 @@
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
+#include "inflate_p.h"
/* function prototypes */
static void fixedtables(struct inflate_state *state);
@@ -105,37 +106,9 @@ static void fixedtables(struct inflate_state *state) {
state->distcode = distfix;
state->distbits = 5;
}
-
-/* Macros for inflateBack(): */
-
-/* Load returned state from inflate_fast() */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Set state from registers for inflate_fast() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
+ Private macros for inflateBack()
+ Look in inflate_p.h for macros shared with inflate()
+*/
/* Assure that some input is available. If input is requested, but denied,
then return a Z_BUF_ERROR from inflateBack(). */
@@ -161,33 +134,6 @@ static void fixedtables(struct inflate_state *state) {
bits += 8; \
} while (0)
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflateBack() with
- an error. */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- (hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
/* Assure that some output space is available, by writing out the window
if it's full. If the write fails, return from inflateBack() with a
Z_BUF_ERROR. */