Skip to content

Commit

Permalink
Avoid deprecated lz4 API.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed May 25, 2019
1 parent 5bd3031 commit 05a2743
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/input.cpp
Expand Up @@ -314,7 +314,7 @@ void Input::EnqueueDecompressSector(uint8_t *src, uint32_t len, uint32_t offset,
uv_.queue_work(loop_, &work_, [this, actualBuf, src, len, isLZ4](uv_work_t *req) {
bool result;
if (isLZ4) {
result = DecompressSectorLZ4(actualBuf, src, csoBlockSize_, decompressError_);
result = DecompressSectorLZ4(actualBuf, src, len, csoBlockSize_, decompressError_);
} else {
result = DecompressSectorDeflate(actualBuf, src, len, type_, decompressError_);
}
Expand Down Expand Up @@ -404,9 +404,9 @@ bool Input::DecompressSectorDeflate(uint8_t *dst, const uint8_t *src, unsigned i
return true;
}

bool Input::DecompressSectorLZ4(uint8_t *dst, const uint8_t *src, int dstSize, std::string &err) {
// Must use fast, because we don't know the size of the input data. It could include padding.
if (LZ4_decompress_fast(reinterpret_cast<const char *>(src), reinterpret_cast<char *>(dst), dstSize) < 0) {
bool Input::DecompressSectorLZ4(uint8_t *dst, const uint8_t *src, unsigned int len, int dstSize, std::string &err) {
// We use partial because we don't know the size of the input data. It could include padding.
if (LZ4_decompress_safe_partial(reinterpret_cast<const char *>(src), reinterpret_cast<char *>(dst), len, dstSize, dstSize) < 0) {
err = "LZ4 decompression failed.";
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/input.h
Expand Up @@ -36,7 +36,7 @@ class Input {
};

static bool DecompressSectorDeflate(uint8_t *dst, const uint8_t *src, unsigned int len, FileType type, std::string &err);
static bool DecompressSectorLZ4(uint8_t *dst, const uint8_t *src, int dstSize, std::string &err);
static bool DecompressSectorLZ4(uint8_t *dst, const uint8_t *src, unsigned int len, int dstSize, std::string &err);

UVHelper uv_;
uv_loop_t *loop_;
Expand Down

0 comments on commit 05a2743

Please sign in to comment.