Skip to content

Commit

Permalink
Merge pull request #13 from psiha/fix/grow_to_crash_for_tiny_increase
Browse files Browse the repository at this point in the history
grow_to:
  • Loading branch information
psiha authored Aug 9, 2024
2 parents b49c329 + f986c10 commit 1182b9a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions include/psi/vm/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
#include <algorithm>
#include <array>
#include <concepts>
#include <cstdint>
#include <climits>
#include <cstdint>
#include <cstring>
#include <memory>
#include <span>
#include <type_traits>
Expand Down Expand Up @@ -1100,7 +1101,14 @@ class vector
storage_.expand( to_byte_sz( target_size ) );
if constexpr ( std::is_trivially_constructible_v<value_type> )
{
std::memset( data() + current_size, 0, target_size - current_size * sizeof( T ) );
[[ maybe_unused ]] auto const newSpaceBegin{ reinterpret_cast<unsigned char const *>( 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
{
Expand Down

0 comments on commit 1182b9a

Please sign in to comment.