/* Output buffer */
static char *obuf;
+static int obuf_size;
/* Send a deflated token */
static void
rprintf(FERROR, "compression init failed\n");
exit_cleanup(RERR_STREAMIO);
}
- if ((obuf = malloc(MAX_DATA_COUNT+2)) == NULL)
+#if MAX_DATA_COUNT+2 > CHUNK_SIZE+128 /* this shouldn't ever happen... */
+ obuf_size = MAX_DATA_COUNT+2;
+#else
+ obuf_size = CHUNK_SIZE+128;
+#endif
+ if ((obuf = malloc(obuf_size)) == NULL)
out_of_memory("send_deflated_token");
init_done = 1;
} else
tx_strm.next_in = (Bytef *) map_ptr(buf, offset, toklen);
tx_strm.avail_in = toklen;
tx_strm.next_out = (Bytef *) obuf;
- tx_strm.avail_out = MAX_DATA_COUNT;
+ tx_strm.avail_out = obuf_size;
r = deflate(&tx_strm, Z_INSERT_ONLY);
if (r != Z_OK || tx_strm.avail_in != 0) {
rprintf(FERROR, "deflate on token returned %d (%d bytes left)\n",
} while (len || rx_strm.avail_out == 0);
}
-/*
- * transmit a verbatim buffer of length n followed by a token
+/**
+ * Transmit a verbatim buffer of length @p n followed by a token.
* If token == -1 then we have reached EOF
* If n == 0 then don't send a buffer
*/