Skip to content
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

Why does mapping require a function? #22

Open
FallingSnow opened this issue Mar 27, 2023 · 1 comment
Open

Why does mapping require a function? #22

FallingSnow opened this issue Mar 27, 2023 · 1 comment

Comments

@FallingSnow
Copy link

FallingSnow commented Mar 27, 2023

Why does mapping require a function to be passed instead of mapping then unmapping on drop?

gbm.rs/src/buffer_object.rs

Lines 299 to 310 in 8fd2021

pub fn map<'a, D, F, S>(
&'a self,
device: &Device<D>,
x: u32,
y: u32,
width: u32,
height: u32,
f: F,
) -> Result<IoResult<S>, WrongDeviceError>
where
D: AsFd + 'static,
F: FnOnce(&MappedBufferObject<'a, T>) -> S,

@FallingSnow FallingSnow changed the title Why does mapping require a function Why does mapping require a function? Mar 27, 2023
@Drakulix
Copy link
Member

This could alternatively be handled by a guard-type, feel free to submit a PR. Key is just, that we block freeing the buffer before the mapping and avoid calling other methods such as write.

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

No branches or pull requests

2 participants