#include "zbuild.h"
#include "deflate.h"
+#include "deflate_p.h"
#include "trees_emit.h"
#include "dfltcc_deflate.h"
#include "dfltcc_detail.h"
deflate_state *state = (deflate_state *)strm->state;
send_bits(state, PREFIX(bi_reverse)(param->eobs >> (15 - param->eobl), param->eobl), param->eobl, state->bi_buf, state->bi_valid);
- PREFIX(flush_pending)(strm);
+ flush_pending_inline(strm);
if (state->pending != 0) {
/* The remaining data is located in pending_out[0:pending]. If someone
* calls put_byte() - this might happen in deflate() - the byte will be
}
/* =========================================================================
- * Flush as much pending output as possible. All deflate() output, except for
- * some deflate_stored() output, goes through this function so some
- * applications may wish to modify it to avoid allocating a large
- * strm->next_out buffer and copying into it. (See also read_buf()).
+ * Flush as much pending output as possible. See flush_pending_inline()
*/
Z_INTERNAL void PREFIX(flush_pending)(PREFIX3(stream) *strm) {
- uint32_t len;
- deflate_state *s = strm->state;
-
- zng_tr_flush_bits(s);
- len = MIN(s->pending, strm->avail_out);
- if (len == 0)
- return;
-
- Tracev((stderr, "[FLUSH]"));
- memcpy(strm->next_out, s->pending_out, len);
- strm->next_out += len;
- s->pending_out += len;
- strm->total_out += len;
- strm->avail_out -= len;
- s->pending -= len;
- if (s->pending == 0)
- s->pending_out = s->pending_buf;
+ flush_pending_inline(strm);
}
/* ===========================================================================
/* Flush as much pending output as possible */
if (s->pending != 0) {
- PREFIX(flush_pending)(strm);
+ flush_pending_inline(strm);
if (strm->avail_out == 0) {
/* Since avail_out is 0, deflate will be called again with
* more output space, but possibly with both pending and
s->status = BUSY_STATE;
/* Compression must start with an empty pending buffer */
- PREFIX(flush_pending)(strm);
+ flush_pending_inline(strm);
if (s->pending != 0) {
s->last_flush = -1;
return Z_OK;
if (s->wrap == 1)
put_uint32_msb(s, strm->adler);
}
- PREFIX(flush_pending)(strm);
+ flush_pending_inline(strm);
/* If avail_out is zero, the application will call deflate again
* to flush the rest.
*/
return (s->sym_next == s->sym_end);
}
+/* =========================================================================
+ * Flush as much pending output as possible. All deflate() output, except for some
+ * deflate_stored() output, goes through this function so some applications may wish to
+ * modify it to avoid allocating a large strm->next_out buffer and copying into it.
+ * See also read_buf().
+ */
+Z_FORCEINLINE static void flush_pending_inline(PREFIX3(stream) *strm) {
+ uint32_t len;
+ deflate_state *s = strm->state;
+
+ zng_tr_flush_bits(s);
+ len = MIN(s->pending, strm->avail_out);
+ if (len == 0)
+ return;
+
+ Tracev((stderr, "[FLUSH]"));
+ memcpy(strm->next_out, s->pending_out, len);
+ strm->next_out += len;
+ s->pending_out += len;
+ strm->total_out += len;
+ strm->avail_out -= len;
+ s->pending -= len;
+ if (s->pending == 0)
+ s->pending_out = s->pending_buf;
+}
+
/* ===========================================================================
* 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