diff options
| author | Stefan Boberg <[email protected]> | 2021-11-18 14:33:44 +0100 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-11-18 14:33:44 +0100 |
| commit | e53df312f3c4dcef19add9cd26afc324557b1f5a (patch) | |
| tree | a3d7b59f29e484d48edffb2a26bbb0dd2d95533d /zencore | |
| parent | gc: implemented timestamped snapshot persistence (diff) | |
| parent | Change error code for failed upsteam apply (diff) | |
| download | zen-e53df312f3c4dcef19add9cd26afc324557b1f5a.tar.xz zen-e53df312f3c4dcef19add9cd26afc324557b1f5a.zip | |
merge from main
Diffstat (limited to 'zencore')
| -rw-r--r-- | zencore/blake3.cpp | 2 | ||||
| -rw-r--r-- | zencore/compactbinary.cpp | 18 | ||||
| -rw-r--r-- | zencore/compress.cpp | 15 | ||||
| -rw-r--r-- | zencore/include/zencore/iobuffer.h | 1 | ||||
| -rw-r--r-- | zencore/memory.cpp | 4 | ||||
| -rw-r--r-- | zencore/xmake.lua | 6 | ||||
| -rw-r--r-- | zencore/zencore.vcxproj | 4 |
7 files changed, 30 insertions, 20 deletions
diff --git a/zencore/blake3.cpp b/zencore/blake3.cpp index 663f21b6d..8f8952271 100644 --- a/zencore/blake3.cpp +++ b/zencore/blake3.cpp @@ -7,7 +7,7 @@ #include <zencore/testing.h> #include <zencore/zencore.h> -#include "../3rdparty/BLAKE3/c/blake3.h" +#include "../thirdparty/BLAKE3/c/blake3.h" #pragma comment(lib, "blake3.lib") #include <string.h> diff --git a/zencore/compactbinary.cpp b/zencore/compactbinary.cpp index aafb365f3..c6bf38b04 100644 --- a/zencore/compactbinary.cpp +++ b/zencore/compactbinary.cpp @@ -1854,11 +1854,11 @@ TEST_CASE("uson.json") << "ValueTwo"; CbObject Obj = Writer.Save(); - StringBuilder<128> Sb; - const std::string_view JsonText = Obj.ToJson(Sb).ToView(); + StringBuilder<128> Sb; + const char* JsonText = Obj.ToJson(Sb).Data(); std::string JsonError; - json11::Json Json = json11::Json::parse(JsonText.data(), JsonError); + json11::Json Json = json11::Json::parse(JsonText, JsonError); const std::string ValueOne = Json["KeyOne"].string_value(); const std::string ValueTwo = Json["KeyTwo"].string_value(); @@ -1879,11 +1879,11 @@ TEST_CASE("uson.json") CbObject Obj = Writer.Save(); - StringBuilder<128> Sb; - const std::string_view JsonText = Obj.ToJson(Sb).ToView(); + StringBuilder<128> Sb; + const char* JsonText = Obj.ToJson(Sb).Data(); std::string JsonError; - json11::Json Json = json11::Json::parse(JsonText.data(), JsonError); + json11::Json Json = json11::Json::parse(JsonText, JsonError); const float FloatValue = float(Json["Float"].number_value()); const double DoubleValue = Json["Double"].number_value(); @@ -1904,11 +1904,11 @@ TEST_CASE("uson.json") CbObject Obj = Writer.Save(); - StringBuilder<128> Sb; - const std::string_view JsonText = Obj.ToJson(Sb).ToView(); + StringBuilder<128> Sb; + const char* JsonText = Obj.ToJson(Sb).Data(); std::string JsonError; - json11::Json Json = json11::Json::parse(JsonText.data(), JsonError); + json11::Json Json = json11::Json::parse(JsonText, JsonError); const double FloatValue = Json["FloatNan"].number_value(); const double DoubleValue = Json["DoubleNan"].number_value(); diff --git a/zencore/compress.cpp b/zencore/compress.cpp index dd6484a3c..35a5acb3a 100644 --- a/zencore/compress.cpp +++ b/zencore/compress.cpp @@ -8,7 +8,7 @@ #include <zencore/endian.h> #include <zencore/testing.h> -#include "../3rdparty/Oodle/include/oodle2.h" +#include "../thirdparty/Oodle/include/oodle2.h" #if ZEN_PLATFORM_WINDOWS # pragma comment(lib, "oo2core_win64.lib") #endif @@ -693,6 +693,11 @@ ValidBufferOrEmpty(BufferType&& CompressedData) CompositeBuffer CopyCompressedRange(const BufferHeader& Header, const CompositeBuffer& CompressedData, uint64_t RawOffset, uint64_t RawSize) { + if (Header.TotalRawSize < RawOffset + RawSize) + { + return CompositeBuffer(); + } + if (Header.Method == CompressionMethod::None) { UniqueBuffer NewCompressedData = UniqueBuffer::Alloc(RawSize); @@ -862,9 +867,11 @@ CompressedBuffer CompressedBuffer::CopyRange(uint64_t RawOffset, uint64_t RawSize) const { using namespace detail; - const BufferHeader Header = BufferHeader::Read(CompressedData); - CompressedBuffer Range; - Range.CompressedData = CopyCompressedRange(Header, CompressedData, RawOffset, RawSize); + const BufferHeader Header = BufferHeader::Read(CompressedData); + const uint64_t TotalRawSize = RawSize < ~uint64_t(0) ? RawSize : Header.TotalRawSize - RawOffset; + + CompressedBuffer Range; + Range.CompressedData = CopyCompressedRange(Header, CompressedData, RawOffset, TotalRawSize); return Range; } diff --git a/zencore/include/zencore/iobuffer.h b/zencore/include/zencore/iobuffer.h index 88a72cbba..04b3b33dd 100644 --- a/zencore/include/zencore/iobuffer.h +++ b/zencore/include/zencore/iobuffer.h @@ -382,6 +382,7 @@ public: ZENCORE_API static IoBuffer MakeFromFileHandle(void* FileHandle, uint64_t Offset = 0, uint64_t Size = ~0ull); ZENCORE_API static IoBuffer ReadFromFileMaybe(IoBuffer& InBuffer); inline static IoBuffer MakeCloneFromMemory(const void* Ptr, size_t Sz) { return IoBuffer(IoBuffer::Clone, Ptr, Sz); } + inline static IoBuffer MakeCloneFromMemory(MemoryView Memory) { return IoBuffer(IoBuffer::Clone, Memory.GetData(), Memory.GetSize()); } }; IoHash HashBuffer(IoBuffer& Buffer); diff --git a/zencore/memory.cpp b/zencore/memory.cpp index 14ea7ca1d..c94829276 100644 --- a/zencore/memory.cpp +++ b/zencore/memory.cpp @@ -186,13 +186,13 @@ TEST_CASE("MemoryView") { { uint8_t Array1[16] = {}; - MemoryView View1 = MakeMemoryView(Array1); + MemoryView View1 = MakeMemoryView(Array1); CHECK(View1.GetSize() == 16); } { uint32_t Array2[16] = {}; - MemoryView View2 = MakeMemoryView(Array2); + MemoryView View2 = MakeMemoryView(Array2); CHECK(View2.GetSize() == 64); } diff --git a/zencore/xmake.lua b/zencore/xmake.lua index 5de7f476d..d26a9f922 100644 --- a/zencore/xmake.lua +++ b/zencore/xmake.lua @@ -2,13 +2,15 @@ target('zencore') set_kind("static") add_files("**.cpp") add_includedirs("include", {public=true}) - add_includedirs("..\\3rdparty\\utfcpp\\source") - add_linkdirs("$(projectdir)/3rdparty/BLAKE3/lib/Win64", "$(projectdir)/3rdparty/Oodle/lib/Win64") + add_includedirs("..\\thirdparty\\utfcpp\\source") + add_linkdirs("$(projectdir)/thirdparty/BLAKE3/lib/Win64", "$(projectdir)/thirdparty/Oodle/lib/Win64") add_packages( "vcpkg::spdlog", "vcpkg::fmt", "vcpkg::doctest", + "vcpkg::json11", "vcpkg::lz4", + "vcpkg::mimalloc", "vcpkg::cpr", "vcpkg::curl", -- required by cpr "vcpkg::zlib", -- required by curl diff --git a/zencore/zencore.vcxproj b/zencore/zencore.vcxproj index 95b9eace5..49e959b96 100644 --- a/zencore/zencore.vcxproj +++ b/zencore/zencore.vcxproj @@ -74,7 +74,7 @@ <SDLCheck>true</SDLCheck> <PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <ConformanceMode>true</ConformanceMode> - <AdditionalIncludeDirectories>.\include;..\3rdparty\utfcpp\source</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>.\include;..\thirdparty\utfcpp\source</AdditionalIncludeDirectories> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <LanguageStandard>stdcpplatest</LanguageStandard> <TreatWarningAsError>true</TreatWarningAsError> @@ -95,7 +95,7 @@ <SDLCheck>true</SDLCheck> <PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <ConformanceMode>true</ConformanceMode> - <AdditionalIncludeDirectories>.\include;..\3rdparty\utfcpp\source</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>.\include;..\thirdparty\utfcpp\source</AdditionalIncludeDirectories> <WholeProgramOptimization>false</WholeProgramOptimization> <LanguageStandard>stdcpplatest</LanguageStandard> <TreatWarningAsError>true</TreatWarningAsError> |