Skip to content

Commit 2183675

Browse files
committed
Have Mmap take ownership of File
1 parent 2fd0265 commit 2183675

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

src/symbolize/gimli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn mmap(path: &Path) -> Option<Mmap> {
188188
let len = file.metadata().ok()?.len().try_into().ok()?;
189189
// SAFETY: All files we mmap are mmaped by the dynamic linker or the kernel already for the
190190
// executable code of the process. Modifying them would cause crashes or UB anyways.
191-
unsafe { Mmap::map(&file, len, 0) }
191+
unsafe { Mmap::map(file, len, 0) }
192192
}
193193

194194
cfg_if::cfg_if! {

src/symbolize/gimli/elf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Mapping {
7171
// NOTE: we map the remainder of the entire archive instead of just the library so we don't have to determine its length
7272
// SAFETY: See `super::mmap` function
7373
let map = unsafe {
74-
super::mmap::Mmap::map(&file, usize::try_from(len - zip_offset).ok()?, zip_offset)
74+
super::mmap::Mmap::map(file, usize::try_from(len - zip_offset).ok()?, zip_offset)
7575
}?;
7676

7777
Mapping::mk(map, |map, stash| {

src/symbolize/gimli/mmap_fake.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ impl Mmap {
1212
///
1313
/// # Safety
1414
/// This function is always safe to call.
15-
pub unsafe fn map(mut file: &File, len: usize, offset: u64) -> Option<Mmap> {
15+
pub unsafe fn map(mut file: File, len: usize, offset: u64) -> Option<Mmap> {
1616
let mut mmap = Mmap {
1717
vec: Vec::with_capacity(len),
1818
};

src/symbolize/gimli/mmap_unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Mmap {
2222
/// - Mapped files must not be altered for the lifetime of the returned value.
2323
///
2424
/// [^1]: https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/mmap.html
25-
pub unsafe fn map(file: &File, len: usize, offset: u64) -> Option<Mmap> {
25+
pub unsafe fn map(file: File, len: usize, offset: u64) -> Option<Mmap> {
2626
let ptr = mmap64(
2727
ptr::null_mut(),
2828
len,

src/symbolize/gimli/mmap_windows.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ impl Mmap {
2323
/// - Mapped files must not be altered for the lifetime of the returned value.'
2424
///
2525
/// [^1]: https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-mapviewoffile
26-
pub unsafe fn map(file: &File, len: usize, offset: u64) -> Option<Mmap> {
27-
let file = file.try_clone().ok()?;
26+
pub unsafe fn map(file: File, len: usize, offset: u64) -> Option<Mmap> {
2827
let mapping = CreateFileMappingA(
2928
file.as_raw_handle(),
3029
ptr::null_mut(),

0 commit comments

Comments
 (0)