From f986c10b50763c4d52160bdcdb02e3db9f617046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domagoj=20=C5=A0ari=C4=87?= Date: Fri, 9 Aug 2024 19:22:55 +0200 Subject: [PATCH] grow_to: - fixed a crash - replaced memseting the new storage with a check expecting it to be prezeroed by the OS. --- include/psi/vm/vector.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/psi/vm/vector.hpp b/include/psi/vm/vector.hpp index 40b3831..1889f46 100644 --- a/include/psi/vm/vector.hpp +++ b/include/psi/vm/vector.hpp @@ -25,8 +25,9 @@ #include #include #include -#include #include +#include +#include #include #include #include @@ -1100,7 +1101,14 @@ class vector storage_.expand( to_byte_sz( target_size ) ); if constexpr ( std::is_trivially_constructible_v ) { - std::memset( data() + current_size, 0, target_size - current_size * sizeof( T ) ); + [[ maybe_unused ]] auto const newSpaceBegin{ reinterpret_cast( data() + current_size ) }; + [[ maybe_unused ]] auto const newSpaceSize { ( target_size - current_size ) * sizeof( value_type ) }; + //std::memset( newSpaceBegin, 0, newSpaceSize ); + BOOST_ASSERT_MSG + ( + *std::max_element( newSpaceBegin, newSpaceBegin + newSpaceSize ) == 0, + "Expecting files to be zero-extended" + ); } else {