diff options
| author | ruki <[email protected]> | 2022-05-08 20:16:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-05-08 20:16:52 +0800 |
| commit | 0c2e5dd8dee21210f800af3196e219fb1296c687 (patch) | |
| tree | 6564946a4fe690d6469bece86c5421dec543cf38 | |
| parent | 3c77f27f93baad4e629126abbe17266d502b9be2 (diff) | |
fix compile errors
| -rw-r--r-- | core/src/xmake/lz4/block_compress.c | 8 | ||||
| -rw-r--r-- | core/src/xmake/lz4/block_decompress.c | 8 | ||||
| -rw-r--r-- | core/src/xmake/lz4/compress.c | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/core/src/xmake/lz4/block_compress.c b/core/src/xmake/lz4/block_compress.c index 199467110..206f22c17 100644 --- a/core/src/xmake/lz4/block_compress.c +++ b/core/src/xmake/lz4/block_compress.c @@ -39,10 +39,10 @@ tb_int_t xm_lz4_block_compress(lua_State* lua) tb_assert_and_check_return_val(lua, 0); // get data and size - tb_size_t size = 0; + tb_int_t size = 0; tb_byte_t const* data = tb_null; if (lua_isnumber(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tonumber(lua, 1); - if (lua_isnumber(lua, 2)) size = (tb_size_t)lua_tonumber(lua, 2); + if (lua_isnumber(lua, 2)) size = (tb_int_t)lua_tointeger(lua, 2); if (!data || !size || size > LZ4_MAX_INPUT_SIZE) { lua_pushnil(lua); @@ -56,10 +56,10 @@ tb_int_t xm_lz4_block_compress(lua_State* lua) tb_byte_t buffer[8192]; do { - tb_size_t output_size = LZ4_compressBound(size); + tb_int_t output_size = LZ4_compressBound(size); tb_assert_and_check_break(output_size); - output_data = output_size <= sizeof(buffer)? buffer : tb_malloc(output_size); + output_data = output_size <= sizeof(buffer)? buffer : (tb_byte_t*)tb_malloc(output_size); tb_assert_and_check_break(output_data); tb_int_t real = LZ4_compress_default((tb_char_t const*)data, (tb_char_t*)output_data, size, output_size); diff --git a/core/src/xmake/lz4/block_decompress.c b/core/src/xmake/lz4/block_decompress.c index 6262566d2..144400521 100644 --- a/core/src/xmake/lz4/block_decompress.c +++ b/core/src/xmake/lz4/block_decompress.c @@ -51,11 +51,11 @@ tb_int_t xm_lz4_block_decompress(lua_State* lua) } // get real size - tb_size_t real = (tb_size_t)lua_tonumber(lua, 3); - if (!real) + tb_int_t real = (tb_int_t)lua_tointeger(lua, 3); + if (real > 0) { lua_pushnil(lua); - lua_pushfstring(lua, "invalid output size(%d)!", (tb_int_t)real); + lua_pushfstring(lua, "invalid output size(%d)!", real); return 2; } @@ -65,7 +65,7 @@ tb_int_t xm_lz4_block_decompress(lua_State* lua) tb_byte_t buffer[8192]; do { - output_data = real <= sizeof(buffer)? buffer : tb_malloc(real); + output_data = real <= sizeof(buffer)? buffer : (tb_byte_t*)tb_malloc(real); tb_assert_and_check_break(output_data); tb_int_t r = LZ4_decompress_fast((tb_char_t const*)data, (tb_char_t*)output_data, real); diff --git a/core/src/xmake/lz4/compress.c b/core/src/xmake/lz4/compress.c index 2bda3ae70..298023b0b 100644 --- a/core/src/xmake/lz4/compress.c +++ b/core/src/xmake/lz4/compress.c @@ -60,7 +60,7 @@ tb_int_t xm_lz4_compress(lua_State* lua) tb_size_t output_size = LZ4F_compressFrameBound(size, tb_null); tb_assert_and_check_break(output_size); - output_data = output_size <= sizeof(buffer)? buffer : tb_malloc(output_size); + output_data = output_size <= sizeof(buffer)? buffer : (tb_byte_t*)tb_malloc(output_size); tb_assert_and_check_break(output_data); tb_size_t real_or_errs = LZ4F_compressFrame(output_data, output_size, data, size, tb_null); |
