aboutsummaryrefslogtreecommitdiff
path: root/zencore/compress.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-15 19:49:20 +0200
committerStefan Boberg <[email protected]>2021-09-15 19:49:20 +0200
commit83ccd52321a23c8f1c8a3228cbbf34b8f199a22b (patch)
tree9cf1fb68651f616aef2fa28000e4f328ef9204d8 /zencore/compress.cpp
parentAdded GetSize/GetData functions to reduce cognitive load and bridge the gap b... (diff)
parentTweaked logging to streamline access, and simplified setup code for new loggers (diff)
downloadzen-83ccd52321a23c8f1c8a3228cbbf34b8f199a22b.tar.xz
zen-83ccd52321a23c8f1c8a3228cbbf34b8f199a22b.zip
Merge branch 'main' into cbpackage-update
Diffstat (limited to 'zencore/compress.cpp')
-rw-r--r--zencore/compress.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/zencore/compress.cpp b/zencore/compress.cpp
index 2b2c4dd0b..12a7b9ef8 100644
--- a/zencore/compress.cpp
+++ b/zencore/compress.cpp
@@ -8,11 +8,14 @@
#include <zencore/endian.h>
#include "../3rdparty/Oodle/include/oodle2.h"
-#pragma comment(lib, "oo2core_win64.lib")
+#if ZEN_PLATFORM_WINDOWS
+# pragma comment(lib, "oo2core_win64.lib")
+#endif
#include <doctest/doctest.h>
#include <lz4.h>
#include <functional>
+#include <limits>
namespace zen::detail {
@@ -100,7 +103,7 @@ struct BufferHeader
constexpr uint64_t MethodOffset = offsetof(BufferHeader, Method);
for (MemoryView View = HeaderView + MethodOffset; const uint64_t ViewSize = View.GetSize();)
{
- const int32_t Size = static_cast<int32_t>(zen::Min<uint64_t>(ViewSize, INT_MAX));
+ const int32_t Size = static_cast<int32_t>(zen::Min<uint64_t>(ViewSize, /* INT_MAX */ 2147483647u));
Crc32 = zen::MemCrc32(View.GetData(), Size, Crc32);
View += Size;
}
@@ -208,7 +211,7 @@ private:
CompositeBuffer
BlockEncoder::Compress(const CompositeBuffer& RawData, const uint64_t BlockSize) const
{
- ZEN_ASSERT(IsPow2(BlockSize) && BlockSize <= (1 << 31));
+ ZEN_ASSERT(IsPow2(BlockSize) && (BlockSize <= (1u << 31)));
const uint64_t RawSize = RawData.GetSize();
BLAKE3Stream RawHash;
@@ -589,7 +592,7 @@ protected:
const int Size = LZ4_decompress_safe(static_cast<const char*>(CompressedData.GetData()),
static_cast<char*>(RawData.GetData()),
static_cast<int>(CompressedData.GetSize()),
- static_cast<int>(zen::Min<uint64_t>(RawData.GetSize(), LZ4_MAX_INPUT_SIZE)));
+ static_cast<int>(zen::Min<uint64_t>(RawData.GetSize(), uint64_t(LZ4_MAX_INPUT_SIZE))));
return static_cast<uint64_t>(Size) == RawData.GetSize();
}
return false;