#mmaped into vec
12 messages · Page 1 of 1 (latest)
any reason you're not using a crate for that?
i'm not all that familiar with mmapping, but what's your reason for using vec?
Vec::leak ?
creating a slice would be a lot safer, and many of vec's methods are actually on slice
note that using Vec::leak for this is just a roundabout way of using slice::from_raw_parts_mut
That doesn't sound right
slice::from_raw_parts(mmaped, 16) should create a valid slice (of course you'll still need to bound the lifetime appropriately)
I think what you want here is to create a slice of &mut [MaybeUninit<u8>]
Probably should also read the code of a crate that does it like
https://docs.rs/memmap2/latest/memmap2/struct.Mmap.html
A handle to an immutable memory mapped buffer.
i would just avoid creating the vec in the first place. It's a bad idea
if you also want to be able to push to the unitialized part of the mmap, you really want to create a wrapper struct around it. And destroy the mmap in its Drop impl etc, etc. I havent looked at the memmap2 crate but i imagine it does something like that