mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
xous: definitions: dispose of Vec on hosted
When running on Hosted mode, reconstitute the Vec and dispose of it rather than freeing the memory by passing it back to the kernel. This is because the data was previously allocated by way of a vec, and only a reconstituted vec knows how to properly dispose of the data. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
486d993c4c
commit
00e9ead818
1 changed files with 10 additions and 0 deletions
|
|
@ -584,6 +584,16 @@ impl Drop for MessageEnvelope {
|
|||
.expect("couldn't return memory")
|
||||
}
|
||||
Message::Move(msg) => {
|
||||
// Reconstitute the vec and drop it right away to ensure it's freed.
|
||||
#[cfg(any(unix, windows))]
|
||||
let _v = unsafe {
|
||||
std::vec::Vec::from_raw_parts(
|
||||
msg.buf.as_mut_ptr(),
|
||||
msg.buf.len(),
|
||||
msg.buf.len(),
|
||||
)
|
||||
};
|
||||
#[cfg(not(any(unix, windows)))]
|
||||
crate::syscall::unmap_memory(msg.buf).expect("couldn't free memory message")
|
||||
}
|
||||
_ => (),
|
||||
|
|
|
|||
Loading…
Reference in a new issue