bpf: add HashMap::remove()

pull/1/head
Alessandro Decina 3 years ago
parent 696ae6079c
commit 240c65507b

@ -73,4 +73,16 @@ impl<K, V> HashMap<K, V> {
Ok(()) Ok(())
} }
pub unsafe fn remove(&mut self, key: &K) -> Result<(), c_long> {
let value = bpf_map_delete_elem(
&mut self.def as *mut _ as *mut _,
key as *const _ as *const c_void,
);
if value < 0 {
Err(value)
} else {
Ok(())
}
}
} }

Loading…
Cancel
Save