diff --git a/src/memory/map.cpp b/src/memory/map.cpp index 0c34eeca..179ba88e 100644 --- a/src/memory/map.cpp +++ b/src/memory/map.cpp @@ -279,7 +279,7 @@ memory_ptr map::set(size_t offset, size_t size, uint8_t backfill) NOEXCEPT // Fill new capacity as offset may not be at end due to expansion. BC_PUSH_WARNING(NO_POINTER_ARITHMETIC) - std::fill_n(memory_map_ + old_capacity, new_capacity - old_capacity, + std::fill_n(memory_map_ + logical_, new_capacity - logical_, backfill); BC_POP_WARNING() } diff --git a/test/memory/map.cpp b/test/memory/map.cpp index 8ca9e541..e1d2738f 100644 --- a/test/memory/map.cpp +++ b/test/memory/map.cpp @@ -549,11 +549,10 @@ BOOST_AUTO_TEST_CASE(map__set__loaded__expected_fill) BOOST_REQUIRE_EQUAL(data[ 5], 'a'); // offset + 0 BOOST_REQUIRE_EQUAL(data[ 6], 'b'); // offset + 1 BOOST_REQUIRE_EQUAL(data[ 7], 'c'); // offset + 2 - BOOST_REQUIRE_EQUAL(data[ 8], fill1); // expansion - BOOST_REQUIRE_EQUAL(data[ 9], fill1); // expansion - BOOST_REQUIRE_EQUAL(data[10], fill1); // expansion - BOOST_REQUIRE_EQUAL(data[11], fill1); // sub1(offset + size + to_half(offset + size)) - + BOOST_REQUIRE_EQUAL(data[ 8], fill2); // expansion, macos trims on remap here. + BOOST_REQUIRE_EQUAL(data[ 9], fill2); // expansion, so it goes to zero if not refilled. + BOOST_REQUIRE_EQUAL(data[10], fill2); // expansion + BOOST_REQUIRE_EQUAL(data[11], fill2); // sub1(offset + size + to_half(offset + size)) BOOST_REQUIRE_EQUAL(data[12], fill2); // cannot assume mmap default fill BOOST_REQUIRE_EQUAL(data[13], fill2); // cannot assume mmap default fill BOOST_REQUIRE_EQUAL(data[14], fill2); // cannot assume mmap default fill