*/
#include "zbuild.h"
+#include "functable.h"
#include "deflate.h"
#include "deflate_p.h"
-#include "functable.h"
/* Avoid conflicts with zlib.h macros */
#ifdef ZLIB_COMPAT
Z_INTERNAL block_state deflate_huff (deflate_state *s, int flush);
static void lm_set_level (deflate_state *s, int level);
static void lm_init (deflate_state *s);
-Z_INTERNAL unsigned read_buf (PREFIX3(stream) *strm, unsigned char *buf, unsigned size);
/* ===========================================================================
* Local data
return Z_OK;
}
-/* ===========================================================================
- * Read a new buffer from the current input stream, update the adler32
- * and total number of bytes read. All deflate() input goes through
- * this function so some applications may wish to modify it to avoid
- * allocating a large strm->next_in buffer and copying from it.
- * (See also flush_pending()).
- */
-Z_INTERNAL unsigned PREFIX(read_buf)(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) {
- uint32_t len = MIN(strm->avail_in, size);
- if (len == 0)
- return 0;
-
- strm->avail_in -= len;
-
- if (!DEFLATE_NEED_CHECKSUM(strm)) {
- memcpy(buf, strm->next_in, len);
-#ifdef GZIP
- } else if (strm->state->wrap == 2) {
- FUNCTABLE_CALL(crc32_fold_copy)(&strm->state->crc_fold, buf, strm->next_in, len);
-#endif
- } else if (strm->state->wrap == 1) {
- strm->adler = FUNCTABLE_CALL(adler32_fold_copy)(strm->adler, buf, strm->next_in, len);
- } else {
- memcpy(buf, strm->next_in, len);
- }
- strm->next_in += len;
- strm->total_in += len;
-
- return len;
-}
-
/* ===========================================================================
* Set longest match variables based on level configuration
*/
*/
Assert(more >= 2, "more < 2");
- n = PREFIX(read_buf)(s->strm, s->window + s->strstart + s->lookahead, more);
+ n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
s->lookahead += n;
/* Initialize the hash value now that we have some input: */
#ifndef DEFLATE_P_H
#define DEFLATE_P_H
+#include "functable.h"
+
/* Forward declare common non-inlined functions declared in deflate.c */
#ifdef ZLIB_DEBUG
#endif
Z_INTERNAL void PREFIX(flush_pending)(PREFIX3(stream) *strm);
-Z_INTERNAL unsigned PREFIX(read_buf)(PREFIX3(stream) *strm, unsigned char *buf, unsigned size);
/* ===========================================================================
* Save the match info and tally the frequency counts. Return true if
return (bitrev8(code >> 8) | (uint16_t)bitrev8(code) << 8) >> (16 - len);
}
+/* ===========================================================================
+ * Read a new buffer from the current input stream, update the adler32 and total number of
+ * bytes read. All deflate() input goes through this function so some applications may wish
+ * to modify it to avoid allocating a large strm->next_in buffer and copying from it.
+ * See also flush_pending_inline().
+ */
+Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) {
+ uint32_t len = MIN(strm->avail_in, size);
+
+ if (len == 0)
+ return 0;
+
+ if (!DEFLATE_NEED_CHECKSUM(strm)) {
+ memcpy(buf, strm->next_in, len);
+#ifdef GZIP
+ } else if (strm->state->wrap == 2) {
+ FUNCTABLE_CALL(crc32_fold_copy)(&strm->state->crc_fold, buf, strm->next_in, len);
+#endif
+ } else if (strm->state->wrap == 1) {
+ strm->adler = FUNCTABLE_CALL(adler32_fold_copy)(strm->adler, buf, strm->next_in, len);
+ } else {
+ memcpy(buf, strm->next_in, len);
+ }
+
+ strm->avail_in -= len;
+ strm->next_in += len;
+ strm->total_in += len;
+ return len;
+}
+
/* ===========================================================================
* Flush the current block, with given end-of-file flag.
* IN assertion: strstart is set to the end of the current match.
* the check value.
*/
if (len) {
- PREFIX(read_buf)(s->strm, s->strm->next_out, len);
+ read_buf(s->strm, s->strm->next_out, len);
s->strm->next_out += len;
s->strm->avail_out -= len;
s->strm->total_out += len;
have = MIN(have, s->strm->avail_in);
if (have) {
- PREFIX(read_buf)(s->strm, s->window + s->strstart, have);
+ read_buf(s->strm, s->window + s->strstart, have);
s->strstart += have;
s->insert += MIN(have, s->w_size - s->insert);
}