Skip to content

Commit 9793c7f

Browse files
mmap addr
1 parent fbebb21 commit 9793c7f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/sys/mman.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,19 @@ pub fn munlockall() -> Result<()> {
417417
///
418418
/// [`mmap(2)`]: https://man7.org/linux/man-pages/man2/mmap.2.html
419419
pub unsafe fn mmap(
420-
addr: *mut c_void,
420+
addr: Option<size_t>,
421421
length: size_t,
422422
prot: ProtFlags,
423423
flags: MapFlags,
424424
fd: RawFd,
425425
offset: off_t,
426426
) -> Result<*mut c_void> {
427-
let ret = libc::mmap(addr, length, prot.bits(), flags.bits(), fd, offset);
427+
let ptr = addr.map_or(
428+
std::ptr::null_mut(),
429+
|a| a as *mut c_void
430+
);
431+
432+
let ret = libc::mmap(ptr, length, prot.bits(), flags.bits(), fd, offset);
428433

429434
if ret == libc::MAP_FAILED {
430435
Err(Errno::last())

0 commit comments

Comments
 (0)