Closed Siarheika closed 12 years ago
Fixed probably from the other bug reported with test data.
Actually the fix was the following: Method overload fixes this Decompress(data, sizeof(Int32), result, 0, data.Length - sizeof(Int32));
public byte[] Compress(byte[] data) { var compressed = LZ4CompressorFactory .CreateNew() // not thread-safe. .Compress(data); var result = new byte[compressed.Length + sizeof(Int32)]; Buffer.BlockCopy(compressed, 0, result, sizeof(Int32), compressed.Length); var lengthData = BitConverter.GetBytes(data.Length); Buffer.BlockCopy(lengthData, 0, result, 0, lengthData.Length); return result; } public byte[] Decompress(byte[] data) { var length = BitConverter.ToInt32(data, 0);
var result = new byte[length];
LZ4DecompressorFactory
.CreateNew() // not thread-safe
.Decompress(data, sizeof(Int32), result, 0, data.Length -
sizeof(Int32)); return result; }
On Tue, Oct 2, 2012 at 11:37 PM, stangelandcl notifications@github.comwrote:
Fixed probably from the other bug reported with test data.
— Reply to this email directly or view it on GitHubhttps://github.com/stangelandcl/LZ4Sharp/issues/7#issuecomment-9085931.
So to be clear it is working for you now and using a different overload fixed it for you so there is nothing that still need to change, correct?
On Tue, Oct 9, 2012 at 2:50 AM, Siarheika notifications@github.com wrote:
Actually the fix was the following: Method overload fixes this Decompress(data, sizeof(Int32), result, 0, data.Length - sizeof(Int32));
public byte[] Compress(byte[] data) { var compressed = LZ4CompressorFactory .CreateNew() // not thread-safe. .Compress(data); var result = new byte[compressed.Length + sizeof(Int32)]; Buffer.BlockCopy(compressed, 0, result, sizeof(Int32), compressed.Length); var lengthData = BitConverter.GetBytes(data.Length); Buffer.BlockCopy(lengthData, 0, result, 0, lengthData.Length); return result; } public byte[] Decompress(byte[] data) { var length = BitConverter.ToInt32(data, 0);
var result = new byte[length]; LZ4DecompressorFactory .CreateNew() // not thread-safe .Decompress(data, sizeof(Int32), result, 0, data.Length - sizeof(Int32)); return result; }
On Tue, Oct 2, 2012 at 11:37 PM, stangelandcl notifications@github.comwrote:
Fixed probably from the other bug reported with test data.
— Reply to this email directly or view it on GitHub< https://github.com/stangelandcl/LZ4Sharp/issues/7#issuecomment-9085931>.
— Reply to this email directly or view it on GitHubhttps://github.com/stangelandcl/LZ4Sharp/issues/7#issuecomment-9251965.
fixed it for you so there is nothing that still need to change, correct? Maybe remove other Decompress( overloads where this size is not passed.
Sorry, I didn't checkin my code for the fix 9 days ago. But it should fix decompressing an unknown length byte[].
So cool so awesome
Decompression of some compressed blocks fails.