diff --git a/src/scheme/mod.rs b/src/scheme/mod.rs index da5f5cd783221cd86b2c8048506d58855ec0a877..83becb8fe07c6f80272fb645773f990dcf6c08d5 100644 --- a/src/scheme/mod.rs +++ b/src/scheme/mod.rs @@ -9,6 +9,7 @@ use alloc::sync::Arc; use alloc::boxed::Box; use alloc::collections::BTreeMap; +use alloc::vec::Vec; use core::sync::atomic::AtomicUsize; use spin::{Once, RwLock, RwLockReadGuard, RwLockWriteGuard}; @@ -234,6 +235,22 @@ impl SchemeList { } Ok(id) } + + /// Remove a scheme + pub fn remove(&mut self, id: SchemeId) { + assert!(self.map.remove(&id).is_some()); + for (_ns, names) in self.names.iter_mut() { + let mut remove = Vec::with_capacity(1); + for (name, name_id) in names.iter() { + if name_id == &id { + remove.push(name.clone()); + } + } + for name in remove { + assert!(names.remove(&name).is_some()); + } + } + } } /// Schemes list