ebpf: PerCpuArray: remove get_mut() and add get_ptr() and get_ptr_mut()

get_mut() wasn't sound as it allowed creating multiple mutable
references.
pull/318/head
Alessandro Decina 2 years ago
parent 1eb9ef5488
commit 82cd3e695a

@ -56,11 +56,13 @@ impl<T> PerCpuArray<T> {
} }
#[inline(always)] #[inline(always)]
pub fn get_mut(&self, index: u32) -> Option<&mut T> { pub fn get_ptr(&self, index: u32) -> Option<*const T> {
unsafe { unsafe { self.lookup(index).map(|p| p.as_ptr() as *const T) }
// FIXME: alignment
self.lookup(index).map(|mut p| p.as_mut())
} }
#[inline(always)]
pub fn get_ptr_mut(&self, index: u32) -> Option<*mut T> {
unsafe { self.lookup(index).map(|p| p.as_ptr()) }
} }
#[inline(always)] #[inline(always)]

Loading…
Cancel
Save