diff options
| author | ruki <[email protected]> | 2022-05-08 19:24:22 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-08 19:24:22 +0800 |
| commit | 8f1991ad6622e0f559492927585d67cc8d80572f (patch) | |
| tree | 1edb104f2974284ebc3f52453fd44f6fed00e2ba | |
| parent | abbe4493ab08bf3c0fcf78e675d82b44157332be (diff) | |
fix compress
| -rw-r--r-- | core/src/xmake/lz4/compress.c | 8 | ||||
| -rw-r--r-- | core/src/xmake/lz4/decompress.c | 2 | ||||
| -rw-r--r-- | xmake/core/compress/lz4.lua | 4 |
3 files changed, 7 insertions, 7 deletions
diff --git a/core/src/xmake/lz4/compress.c b/core/src/xmake/lz4/compress.c index e51c991f6..2bda3ae70 100644 --- a/core/src/xmake/lz4/compress.c +++ b/core/src/xmake/lz4/compress.c @@ -63,14 +63,14 @@ tb_int_t xm_lz4_compress(lua_State* lua) output_data = output_size <= sizeof(buffer)? buffer : tb_malloc(output_size); tb_assert_and_check_break(output_data); - tb_size_t err = LZ4F_compressFrame(output_data, output_size, data, size, tb_null); - if (LZ4F_isError(err)) + tb_size_t real_or_errs = LZ4F_compressFrame(output_data, output_size, data, size, tb_null); + if (LZ4F_isError(real_or_errs)) { - error = LZ4F_getErrorName(err); + error = LZ4F_getErrorName(real_or_errs); break; } - lua_pushlstring(lua, (tb_char_t const*)output_data, output_size); + lua_pushlstring(lua, (tb_char_t const*)output_data, real_or_errs); ok = tb_true; } while (0); diff --git a/core/src/xmake/lz4/decompress.c b/core/src/xmake/lz4/decompress.c index 2fad208a2..44cdf79d4 100644 --- a/core/src/xmake/lz4/decompress.c +++ b/core/src/xmake/lz4/decompress.c @@ -66,7 +66,7 @@ tb_int_t xm_lz4_decompress(lua_State* lua) tb_bool_t failed = tb_false; while (1) { - tb_size_t advance = size; + size_t advance = (size_t)size; size_t buffer_size = sizeof(buffer); code = LZ4F_decompress(ctx, buffer, &buffer_size, data, &advance, tb_null); if (LZ4F_isError(code)) diff --git a/xmake/core/compress/lz4.lua b/xmake/core/compress/lz4.lua index 803e9cf0b..c6fed7cf0 100644 --- a/xmake/core/compress/lz4.lua +++ b/xmake/core/compress/lz4.lua @@ -47,7 +47,7 @@ function lz4.compress(data, opt) local dataaddr = data:caddr() local result, errors = lz4._compress(dataaddr, datasize) if not result then - return nil, errors or string.format("compress lz4 data failed") + return nil, errors or string.format("compress lz4 data failed, %s", errors or "unknown") end return bytes(result) end @@ -64,7 +64,7 @@ function lz4.decompress(data, opt) local dataaddr = data:caddr() local result, errors = lz4._decompress(dataaddr, datasize) if not result then - return nil, string.format("decompress lz4 data failed") + return nil, string.format("decompress lz4 data failed, %s", errors or "unknown") end return bytes(result) end |
