From 6a1a2d4aa54c314b372477bfaeb91e44cebe7df0 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Feb 2019 19:40:39 +0100 Subject: [PATCH] core: Do not link LZ4 to core. Use common/data_compression for nso segment decompression instead. --- src/core/CMakeLists.txt | 2 +- src/core/loader/nso.cpp | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 9e23afe85..c59107102 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -458,7 +458,7 @@ add_library(core STATIC create_target_directory_groups(core) target_link_libraries(core PUBLIC common PRIVATE audio_core video_core) -target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt lz4_static mbedtls opus unicorn open_source_archives) +target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt mbedtls opus unicorn open_source_archives) if (ENABLE_WEB_SERVICE) target_compile_definitions(core PRIVATE -DENABLE_WEB_SERVICE) target_link_libraries(core PRIVATE web_service) diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 714d85a59..8aeabe409 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp @@ -4,7 +4,8 @@ #include #include -#include + +#include "common/data_compression.h" #include "common/common_funcs.h" #include "common/file_util.h" #include "common/hex_util.h" @@ -35,15 +36,11 @@ static_assert(sizeof(MODHeader) == 0x1c, "MODHeader has incorrect size."); std::vector DecompressSegment(const std::vector& compressed_data, const NSOSegmentHeader& header) { - std::vector uncompressed_data(header.size); - const int bytes_uncompressed = - LZ4_decompress_safe(reinterpret_cast(compressed_data.data()), - reinterpret_cast(uncompressed_data.data()), - static_cast(compressed_data.size()), header.size); + const std::vector uncompressed_data = + Compression::DecompressDataLZ4(compressed_data, header.size); - ASSERT_MSG(bytes_uncompressed == static_cast(header.size) && - bytes_uncompressed == static_cast(uncompressed_data.size()), - "{} != {} != {}", bytes_uncompressed, header.size, uncompressed_data.size()); + ASSERT_MSG(uncompressed_data.size() == static_cast(header.size), + "{} != {}", header.size, uncompressed_data.size()); return uncompressed_data; }