diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-05-14 15:29:27 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-05-14 15:29:27 +0700 |
commit | 095a665b1c049aa2f757ce62ae411eadde4a67fc (patch) | |
tree | befcf30e4fa5317f9c9fcea6a60092381b20eb36 /crypto/src | |
parent | Merge branch 'rastrup-patch-5' (diff) | |
download | BouncyCastle.NET-ed25519-095a665b1c049aa2f757ce62ae411eadde4a67fc.tar.xz |
Refactor to not need pending_buf_size
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/util/zlib/Deflate.cs | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/crypto/src/util/zlib/Deflate.cs b/crypto/src/util/zlib/Deflate.cs index 99878c01d..90f8eb09c 100644 --- a/crypto/src/util/zlib/Deflate.cs +++ b/crypto/src/util/zlib/Deflate.cs @@ -174,7 +174,6 @@ namespace Org.BouncyCastle.Utilities.Zlib { internal ZStream strm; // pointer back to this zlib stream internal int status; // as the name implies internal byte[] pending_buf; // output still pending - internal int pending_buf_size; // size of pending_buf internal int pending_out; // next pending byte to output to the stream internal int pending; // nb of bytes in the pending buffer internal int noheader; // suppress zlib header and adler32 @@ -802,13 +801,9 @@ namespace Org.BouncyCastle.Utilities.Zlib { // Stored blocks are limited to 0xffff bytes, pending_buf is limited // to pending_buf_size, and each stored block has a 5 byte header: - int max_block_size = 0xffff; + int max_block_size = System.Math.Min(0xffff, pending_buf.Length - 5); int max_start; - if(max_block_size > pending_buf_size - 5) { - max_block_size = pending_buf_size - 5; - } - // Copy as much as possible from input to output: while(true){ // Fill the window as much as possible: @@ -1382,7 +1377,6 @@ namespace Org.BouncyCastle.Utilities.Zlib { // We overlay pending_buf and d_buf+l_buf. This works since the average // output size for (length,distance) codes is <= 24 bits. pending_buf = new byte[lit_bufsize*4]; - pending_buf_size = lit_bufsize*4; d_buf = lit_bufsize; l_buf = (1+2)*lit_bufsize; |