Skip to content

Commit 8cec6cc

Browse files
Merge pull request #60 from triblespace/codex/add-mmap-length-check-before-flush
Avoid flushing empty mmaps in Section::freeze
2 parents b0702c8 + 8e743f3 commit 8cec6cc

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## Unreleased
4+
- avoid flushing empty memory maps in `Section::freeze` to prevent macOS errors
45
- derived zerocopy traits for `SectionHandle` to allow storing handles in `ByteArea` sections
56
- added example demonstrating `ByteArea` with multiple typed sections, concurrent mutations, and freezing or persisting the area
67
- added example combining Python bindings with winnow parsing

INVENTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
## Desired Functionality
77
- Add Kani proofs for winnow view helpers.
8+
- Add test covering freezing an empty section to guard against flush errors on macOS.
89

910
## Discovered Issues
1011
- None at the moment.

src/area.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ where
176176

177177
/// Freeze the section and return immutable [`Bytes`].
178178
pub fn freeze(self) -> io::Result<Bytes> {
179-
self.mmap.flush()?;
179+
if self.mmap.len() > 0 {
180+
self.mmap.flush()?;
181+
}
180182
let len_bytes = self.elems * core::mem::size_of::<T>();
181183
let offset = self.offset;
182184
// Convert the writable mapping into a read-only view instead of

0 commit comments

Comments
 (0)