Skip to content

Commit ecb35cc

Browse files
committed
Backfill to logical on set() head expand.
1 parent 5f140df commit ecb35cc

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/memory/map.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ memory_ptr map::set(size_t offset, size_t size, uint8_t backfill) NOEXCEPT
279279

280280
// Fill new capacity as offset may not be at end due to expansion.
281281
BC_PUSH_WARNING(NO_POINTER_ARITHMETIC)
282-
std::fill_n(memory_map_ + old_capacity, new_capacity - old_capacity,
282+
std::fill_n(memory_map_ + logical_, new_capacity - logical_,
283283
backfill);
284284
BC_POP_WARNING()
285285
}

test/memory/map.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,11 +549,10 @@ BOOST_AUTO_TEST_CASE(map__set__loaded__expected_fill)
549549
BOOST_REQUIRE_EQUAL(data[ 5], 'a'); // offset + 0
550550
BOOST_REQUIRE_EQUAL(data[ 6], 'b'); // offset + 1
551551
BOOST_REQUIRE_EQUAL(data[ 7], 'c'); // offset + 2
552-
BOOST_REQUIRE_EQUAL(data[ 8], fill1); // expansion
553-
BOOST_REQUIRE_EQUAL(data[ 9], fill1); // expansion
554-
BOOST_REQUIRE_EQUAL(data[10], fill1); // expansion
555-
BOOST_REQUIRE_EQUAL(data[11], fill1); // sub1(offset + size + to_half(offset + size))
556-
552+
BOOST_REQUIRE_EQUAL(data[ 8], fill2); // expansion, macos trims on remap here.
553+
BOOST_REQUIRE_EQUAL(data[ 9], fill2); // expansion, so it goes to zero if not refilled.
554+
BOOST_REQUIRE_EQUAL(data[10], fill2); // expansion
555+
BOOST_REQUIRE_EQUAL(data[11], fill2); // sub1(offset + size + to_half(offset + size))
557556
BOOST_REQUIRE_EQUAL(data[12], fill2); // cannot assume mmap default fill
558557
BOOST_REQUIRE_EQUAL(data[13], fill2); // cannot assume mmap default fill
559558
BOOST_REQUIRE_EQUAL(data[14], fill2); // cannot assume mmap default fill

0 commit comments

Comments
 (0)