std.zlib.crc32 and std.zlib.adler32 64-bit underflow|error when processing over 2^32 bytes of data fix

This commit is contained in:
Superstar64 2014-09-04 14:48:35 -04:00
parent 4efb875a7a
commit f79af5f018

View file

@ -67,8 +67,12 @@ class ZlibException : Exception
uint adler32(uint adler, const(void)[] buf)
{
return etc.c.zlib.adler32(adler, cast(ubyte *)buf.ptr,
to!uint(buf.length));
import std.range : chunks;
foreach(chunk; (cast(ubyte[])buf).chunks(0xFFFF0000))
{
adler = etc.c.zlib.adler32(adler, chunk.ptr, cast(uint)chunk.length);
}
return adler;
}
unittest
@ -90,7 +94,12 @@ unittest
uint crc32(uint crc, const(void)[] buf)
{
return etc.c.zlib.crc32(crc, cast(ubyte *)buf.ptr, to!uint(buf.length));
import std.range : chunks;
foreach(chunk; (cast(ubyte[])buf).chunks(0xFFFF0000))
{
crc = etc.c.zlib.crc32(crc, chunk.ptr, cast(uint)chunk.length);
}
return crc;
}
unittest