Skip to content

Implement from_raw and into_raw #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

StephanvanSchaik
Copy link
Owner

This PR implements Mmap::into_raw() to turn an existing memory mapping object into a raw pointer and the size of the memory mapping. After calling this function the user is responsible for the memory previously managed by the memory mapping object.

In addition, this PR implements Mmap::from_raw() to create a memory mapping object from a raw pointer and a size. This is unsafe since the user can call this function more than once for the same raw pointer, which would result in a double-free. Furthermore, the current implementation does not check whether the memory mapping has the appropriate permissions, or whether it even exists.

@StephanvanSchaik StephanvanSchaik force-pushed the from_into_raw branch 5 times, most recently from 82439f4 to 8718e96 Compare June 19, 2023 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant