mirror of https://github.com/AxioDL/lzokay.git
Merge branch 'master' of https://github.com/jackoalan/lzokay
This commit is contained in:
commit
671e2b9864
14
README.md
14
README.md
|
@ -26,22 +26,24 @@ Usage
|
|||
int compress_and_decompress(const uint8_t* data, std::size_t length) {
|
||||
lzokay::EResult error;
|
||||
|
||||
/* This variable and 5th parameter of compress() is optional, but may
|
||||
/* This variable and 6th parameter of compress() is optional, but may
|
||||
* be reused across multiple compression runs; avoiding repeat
|
||||
* allocation/deallocation of the work memory used by the compressor.
|
||||
*/
|
||||
lzokay::Dict<> dict;
|
||||
|
||||
std::size_t compressed_size = lzokay::compress_worst_size(length);
|
||||
std::unique_ptr<uint8_t[]> compressed(new uint8_t[compressed_size]);
|
||||
error = lzokay::compress(data, length, compressed.get(), compressed_size, dict);
|
||||
std::size_t estimated_size = lzokay::compress_worst_size(length);
|
||||
std::unique_ptr<uint8_t[]> compressed(new uint8_t[estimated_size]);
|
||||
std::size_t compressed_size;
|
||||
error = lzokay::compress(data, length, compressed.get(), estimated_size,
|
||||
compressed_size, dict);
|
||||
if (error < lzokay::EResult::Success)
|
||||
return 1;
|
||||
|
||||
std::unique_ptr<uint8_t[]> decompressed(new uint8_t[length]);
|
||||
std::size_t decompressed_size = length;
|
||||
std::size_t decompressed_size;
|
||||
error = lzokay::decompress(compressed.get(), compressed_size,
|
||||
decompressed.get(), decompressed_size);
|
||||
decompressed.get(), length, decompressed_size);
|
||||
if (error < lzokay::EResult::Success)
|
||||
return 1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue