libcortex_a9/sync_channel: fixed memory leak
ptr::drop_in_place would not drop the box content properly, the best way is to convert it back to a box and implicitly drop it.
This commit is contained in:
parent
273f9ea72b
commit
73e4e4fd03
@ -1,7 +1,6 @@
|
|||||||
use core::{
|
use core::{
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
future::Future,
|
future::Future,
|
||||||
ptr::drop_in_place,
|
|
||||||
sync::atomic::{AtomicPtr, AtomicUsize, Ordering},
|
sync::atomic::{AtomicPtr, AtomicUsize, Ordering},
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
};
|
};
|
||||||
@ -38,7 +37,7 @@ impl<'a, T> Sender<'a, T> where T: Clone {
|
|||||||
notify_spin_lock();
|
notify_spin_lock();
|
||||||
if !prev.is_null() {
|
if !prev.is_null() {
|
||||||
unsafe {
|
unsafe {
|
||||||
drop_in_place(prev);
|
Box::from_raw(prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -92,7 +91,7 @@ impl<'a, T> Sender<'a, T> where T: Clone {
|
|||||||
for v in self.list.iter() {
|
for v in self.list.iter() {
|
||||||
let original = v.swap(core::ptr::null_mut(), Ordering::Relaxed);
|
let original = v.swap(core::ptr::null_mut(), Ordering::Relaxed);
|
||||||
if !original.is_null() {
|
if !original.is_null() {
|
||||||
drop_in_place(original);
|
Box::from_raw(original);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user