Skip to content

Commit 671e2b9

Browse files
committed
2 parents 5c6f05a + c92240c commit 671e2b9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,24 @@ Usage
2626
int compress_and_decompress(const uint8_t* data, std::size_t length) {
2727
lzokay::EResult error;
2828

29-
/* This variable and 5th parameter of compress() is optional, but may
29+
/* This variable and 6th parameter of compress() is optional, but may
3030
* be reused across multiple compression runs; avoiding repeat
3131
* allocation/deallocation of the work memory used by the compressor.
3232
*/
3333
lzokay::Dict<> dict;
3434

35-
std::size_t compressed_size = lzokay::compress_worst_size(length);
36-
std::unique_ptr<uint8_t[]> compressed(new uint8_t[compressed_size]);
37-
error = lzokay::compress(data, length, compressed.get(), compressed_size, dict);
35+
std::size_t estimated_size = lzokay::compress_worst_size(length);
36+
std::unique_ptr<uint8_t[]> compressed(new uint8_t[estimated_size]);
37+
std::size_t compressed_size;
38+
error = lzokay::compress(data, length, compressed.get(), estimated_size,
39+
compressed_size, dict);
3840
if (error < lzokay::EResult::Success)
3941
return 1;
4042

4143
std::unique_ptr<uint8_t[]> decompressed(new uint8_t[length]);
42-
std::size_t decompressed_size = length;
44+
std::size_t decompressed_size;
4345
error = lzokay::decompress(compressed.get(), compressed_size,
44-
decompressed.get(), decompressed_size);
46+
decompressed.get(), length, decompressed_size);
4547
if (error < lzokay::EResult::Success)
4648
return 1;
4749

0 commit comments

Comments
 (0)