aboutsummaryrefslogtreecommitdiff
path: root/zencore
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-11-01 16:48:55 +0100
committerStefan Boberg <[email protected]>2021-11-01 16:48:55 +0100
commita8f9941f5c8dff75f606e130f7132babda6265bb (patch)
treeb5d424562420223495fdbcdd6c9dab051519e8ce /zencore
parentfilecas: Fixed debug logging (diff)
parentMerged from main (diff)
downloadzen-a8f9941f5c8dff75f606e130f7132babda6265bb.tar.xz
zen-a8f9941f5c8dff75f606e130f7132babda6265bb.zip
Merge branch 'gc' of https://github.com/EpicGames/zen into gc
Diffstat (limited to 'zencore')
-rw-r--r--zencore/filesystem.cpp2
-rw-r--r--zencore/include/zencore/sharedbuffer.h6
-rw-r--r--zencore/memory.cpp4
3 files changed, 9 insertions, 3 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp
index b8e8eff55..a642e2cf6 100644
--- a/zencore/filesystem.cpp
+++ b/zencore/filesystem.cpp
@@ -840,7 +840,7 @@ TEST_CASE("filesystem")
// GetExePath -- this is not a great test as it's so dependent on where the this code gets linked in
path BinPath = GetRunningExecutablePath();
- const bool ExpectedExe = BinPath.stem() == "zencore-test" || BinPath.stem() == "zenserver-test" || BinPath.stem() == "zenstore-test";
+ const bool ExpectedExe = ToUtf8(BinPath.stem().native()).ends_with("-test"sv) || BinPath.stem() == "zenserver";
CHECK(ExpectedExe);
CHECK(is_regular_file(BinPath));
diff --git a/zencore/include/zencore/sharedbuffer.h b/zencore/include/zencore/sharedbuffer.h
index 640c3fe74..1f87dc639 100644
--- a/zencore/include/zencore/sharedbuffer.h
+++ b/zencore/include/zencore/sharedbuffer.h
@@ -143,6 +143,12 @@ public:
/** Make a non-owned view of the input */
[[nodiscard]] inline static SharedBuffer MakeView(MemoryView View) { return MakeView(View.GetData(), View.GetSize()); }
+ /** Make a non-owning view of the memory of the contiguous container. */
+ [[nodiscard]] inline static SharedBuffer MakeView(const std::ranges::contiguous_range auto& Container)
+ {
+ std::span Span = Container;
+ return MakeView(Span.data(), Span.size() * sizeof(typename decltype(Span)::element_type));
+ }
/** Make a non-owned view of the input */
[[nodiscard]] ZENCORE_API static SharedBuffer MakeView(const void* Data, uint64_t Size);
/** Make a non-owned view of the input */
diff --git a/zencore/memory.cpp b/zencore/memory.cpp
index 62c81076d..14ea7ca1d 100644
--- a/zencore/memory.cpp
+++ b/zencore/memory.cpp
@@ -185,13 +185,13 @@ TEST_CASE("ChunkingLinearAllocator")
TEST_CASE("MemoryView")
{
{
- uint8_t Array1[16];
+ uint8_t Array1[16] = {};
MemoryView View1 = MakeMemoryView(Array1);
CHECK(View1.GetSize() == 16);
}
{
- uint32_t Array2[16];
+ uint32_t Array2[16] = {};
MemoryView View2 = MakeMemoryView(Array2);
CHECK(View2.GetSize() == 64);
}