diff options
| -rw-r--r-- | core/src/xmake/lz4/block_decompress.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/core/src/xmake/lz4/block_decompress.c b/core/src/xmake/lz4/block_decompress.c index 294cb3648..d4c656280 100644 --- a/core/src/xmake/lz4/block_decompress.c +++ b/core/src/xmake/lz4/block_decompress.c @@ -65,20 +65,10 @@ tb_int_t xm_lz4_block_decompress(lua_State* lua) tb_byte_t buffer[8192]; do { - tb_int_t buffer_maxn; - if (real <= sizeof(buffer)) - { - output_data = buffer; - buffer_maxn = sizeof(buffer); - } - else - { - buffer_maxn = real << 1; - output_data = (tb_byte_t*)tb_malloc(buffer_maxn); - } + output_data = real <= sizeof(buffer)? buffer : (tb_byte_t*)tb_malloc(buffer_maxn); tb_assert_and_check_break(output_data); - tb_int_t r = LZ4_decompress_safe((tb_char_t const*)data, (tb_char_t*)output_data, real, buffer_maxn); + tb_int_t r = LZ4_decompress_safe((tb_char_t const*)data, (tb_char_t*)output_data, real, real); tb_assert_and_check_break(r > 0); lua_pushlstring(lua, (tb_char_t const*)output_data, real); |
