[Issue 3191] std.zlib.UnCompress errors if buffer is reused

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 11 16:17:28 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=3191

--- Comment #5 from Stewart Gordon <smjg at iname.com> ---
(In reply to Justin Whear from comment #3)
> The DEFLATE decompression algorithm relies on the results of previous
> blocks, as it tries to reuse the encoding tree.  From the RFC: "Note that a
> duplicated string reference may refer to a string in a previous block; i.e.,
> the backward distance may cross one or more block boundaries.

If I'm not mistaken, deflate blocks are independent of chunks that the
datastream may be split into for decompression.  (OK, maybe "block" was the
wrong word in my original bug report.)

That said,
(In reply to Justin Whear from comment #4)
> I should note that some amount of block reuse is possible if the blocks are
> sufficiently distant; the maximum distance for a back reference is 32,768
> bytes.

This says to me that it is a window of 32768 bytes (or maybe 32769 or 32770
bytes) that needs to be kept in memory at a given time, regardless of block or
chunk boundaries.  So why did I find that alternating between buffers works
even if the buffers are much smaller than this?  (Indeed, I've a vague
recollection of finding that it works if each of the buffers is a single byte.)

--


More information about the Digitalmars-d-bugs mailing list