mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
xous: buffer: impl Drop for Buffer
This will release a Buffer to the kernel when it goes out of scope. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
6119c78bc7
commit
f361bd6e7e
1 changed files with 9 additions and 0 deletions
|
|
@ -94,6 +94,7 @@ impl<'a> XousBuffer<'a> {
|
|||
Ok(result)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> core::convert::AsRef<[u8]> for XousBuffer<'a> {
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
self.slice
|
||||
|
|
@ -119,3 +120,11 @@ impl<'a> core::ops::DerefMut for XousBuffer<'a> {
|
|||
&mut *self.slice
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Drop for XousBuffer<'a> {
|
||||
fn drop(&mut self) {
|
||||
if self.should_drop {
|
||||
crate::unmap_memory(self.range).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue