flashburn
flashburn

Reputation: 4508

LZ4_decompress_safe vs LZ4_decompress_safe_partial

What is the difference between LZ4_decompress_safe and LZ4_decompress_safe_partial? I understand that LZ4_decompress_safe_partial does partial decompression, but it looks like LZ4_decompress_safe also can do partial decompression or I am wrong. Both function signatures have input and output buffers and both have sizes of those buffers as function arguments. And that's why I am asking about it. Say I have a buffer with compressed data and want to decompress only a portion of it. What would be the difference between using LZ4_decompress_safe and LZ4_decompress_safe_partial. Would I get the same result?

Upvotes: 2

Views: 1487

Answers (1)

Cyan
Cyan

Reputation: 13948

it looks like LZ4_decompress_safe also can do partial decompression

That's incorrect. LZ4_decompress_safe() is expected to decompress full blocks, only. It will return an error code if one tries to use it for partial decompression.

Generally speaking, LZ4_decompress_safe_partial() is more powerful, because it can do both full and partial blocks. That being said, its strength is its weakness : if your application wants to know if the block was fully decoded or not, LZ4_decompress_safe_partial() will not provide a useful signal for that: it will happily stop in the middle of the block if instructed to do so. It's also slightly more complex, internally, which may result in slightly slower decoding speed.

Upvotes: 1

Related Questions