diff options
Diffstat (limited to '')
-rw-r--r-- | src/common/zstd_compression.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/common/zstd_compression.cpp b/src/common/zstd_compression.cpp index 978526492..770833ee7 100644 --- a/src/common/zstd_compression.cpp +++ b/src/common/zstd_compression.cpp @@ -5,19 +5,18 @@ #include <algorithm> #include <zstd.h> -#include "common/assert.h" #include "common/zstd_compression.h" namespace Common::Compression { -std::vector<u8> CompressDataZSTD(const u8* source, std::size_t source_size, s32 compression_level) { +std::vector<u8> CompressDataZSTD(std::span<const u8> source, s32 compression_level) { compression_level = std::clamp(compression_level, 1, ZSTD_maxCLevel()); - const std::size_t max_compressed_size = ZSTD_compressBound(source_size); + const std::size_t max_compressed_size = ZSTD_compressBound(source.size()); std::vector<u8> compressed(max_compressed_size); - const std::size_t compressed_size = - ZSTD_compress(compressed.data(), compressed.size(), source, source_size, compression_level); + const std::size_t compressed_size = ZSTD_compress( + compressed.data(), compressed.size(), source.data(), source.size(), compression_level); if (ZSTD_isError(compressed_size)) { // Compression failed @@ -29,8 +28,8 @@ std::vector<u8> CompressDataZSTD(const u8* source, std::size_t source_size, s32 return compressed; } -std::vector<u8> CompressDataZSTDDefault(const u8* source, std::size_t source_size) { - return CompressDataZSTD(source, source_size, ZSTD_CLEVEL_DEFAULT); +std::vector<u8> CompressDataZSTDDefault(std::span<const u8> source) { + return CompressDataZSTD(source, ZSTD_CLEVEL_DEFAULT); } std::vector<u8> DecompressDataZSTD(const std::vector<u8>& compressed) { |