From c2fb67615d6ea9e2f818f4ec58274e8c3a1a40b8 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 18 Nov 2019 00:12:02 -0600 Subject: [PATCH] refactor zlib --- src/zlib/Tiny_httpd_zlib.ml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/zlib/Tiny_httpd_zlib.ml b/src/zlib/Tiny_httpd_zlib.ml index 8dcbadb8..36ae7487 100644 --- a/src/zlib/Tiny_httpd_zlib.ml +++ b/src/zlib/Tiny_httpd_zlib.ml @@ -20,11 +20,10 @@ let mk_decode_deflate_stream_ () (is:S.byte_stream) : S.byte_stream = len !buf_len ); write_offset := !write_offset + len; - buf_len := !buf_len - len; in let bs_fill_buf () : _*_*_ = (* refill [buf] if needed *) - if !buf_len = 0 && not !is_done then ( + if !write_offset >= !buf_len && not !is_done then ( let ib, ioff, ilen = is.S.bs_fill_buf () in begin try @@ -45,7 +44,7 @@ let mk_decode_deflate_stream_ () (is:S.byte_stream) : S.byte_stream = end; S._debug (fun k->k "inflate: refill %d bytes into internal buf" !buf_len); ); - buf, !write_offset, !buf_len + buf, !write_offset, !buf_len - !write_offset in {S.bs_fill_buf; bs_consume; bs_close}