diff --git a/src/kernel/thread_manager.rs b/src/kernel/thread_manager.rs index 298d6cf..f5368cf 100644 --- a/src/kernel/thread_manager.rs +++ b/src/kernel/thread_manager.rs @@ -139,7 +139,7 @@ impl ThreadManager { pub fn thread_finish(&mut self, machine: &mut Machine, thread: Rc>) { let old_status = machine.interrupt.set_status(InterruptStatus::InterruptOff); self.g_thread_to_be_destroyed = Option::Some(Rc::clone(&thread)); - self.g_alive.remove(&Rc::clone(&thread)); + self.g_alive.remove(Rc::clone(&thread)); // g_objets_addrs->removeObject(self.thread) // a ajouté plus tard self.thread_sleep(machine, Rc::clone(&thread)); machine.interrupt.set_status(old_status); diff --git a/src/utility/list.rs b/src/utility/list.rs index 9fb41bd..801a74e 100644 --- a/src/utility/list.rs +++ b/src/utility/list.rs @@ -108,13 +108,14 @@ impl List { /// Return true if the item has been found, otherwise return false /// /// Worst-case complexity is O(n) - pub fn remove(&mut self, item: &T)-> bool { + pub fn remove(&mut self, item: T)-> bool { unsafe { let mut current: *mut Node = self.head; let mut previous: *mut Node = ptr::null_mut(); while !current.is_null() { - if &(*current).elem == item { + if (*current).elem == item { (*previous).next = (*current).next; + drop(Box::from_raw(current).elem); return true; } else { previous = current; @@ -312,11 +313,11 @@ mod test { list.push(3); assert_eq!(list.contains(&2), true); - list.remove(&2); + list.remove(2); assert_eq!(list.contains(&2), false); assert_eq!(list.pop(), Option::Some(1)); assert_eq!(list.pop(), Option::Some(3)); - assert_eq!(list.pop(), Option::None); + assert_eq!(list.peek(), Option::None); } #[test]