*: check unsafe slice creation
This commit is contained in:
parent
ca907c57f3
commit
fafcf1d433
@ -88,13 +88,15 @@ impl<'a> Vector<'a> {
|
|||||||
|
|
||||||
pub fn coefficients(&self) -> &[f64] {
|
pub fn coefficients(&self) -> &[f64] {
|
||||||
unsafe {
|
unsafe {
|
||||||
slice::from_raw_parts((*self.as_ptr()).coeff, (*self.as_ptr()).length as usize)
|
slice::from_raw_parts((*self.as_ptr()).coeff,
|
||||||
|
(*self.as_ptr()).length as usize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn coefficients_mut(&self) -> &[f64] {
|
pub fn coefficients_mut(&self) -> &[f64] {
|
||||||
unsafe {
|
unsafe {
|
||||||
slice::from_raw_parts_mut((*self.as_ptr()).coeff, (*self.as_ptr()).length as usize)
|
slice::from_raw_parts_mut((*self.as_ptr()).coeff,
|
||||||
|
(*self.as_ptr()).length as usize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,8 @@ impl Index<usize> for Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
slice::from_raw_parts(*self.buffer.offset(index as isize), self.size as usize)
|
slice::from_raw_parts(*self.buffer.offset(index as isize),
|
||||||
|
self.size as usize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,9 +157,8 @@ impl Audio {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
slice::from_raw_parts(
|
slice::from_raw_parts(mem::transmute((*self.as_ptr()).data[index]),
|
||||||
mem::transmute((*self.as_ptr()).data[index]),
|
self.samples())
|
||||||
mem::size_of::<T>() * self.samples())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,9 +173,8 @@ impl Audio {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
slice::from_raw_parts_mut(
|
slice::from_raw_parts_mut(mem::transmute((*self.as_mut_ptr()).data[index]),
|
||||||
mem::transmute((*self.as_mut_ptr()).data[index]),
|
self.samples())
|
||||||
mem::size_of::<T>() * self.samples())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ impl Video {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn plane_mut<T: Component>(&mut self, index: usize) -> &mut[T] {
|
pub fn plane_mut<T: Component>(&mut self, index: usize) -> &mut [T] {
|
||||||
if index >= self.planes() {
|
if index >= self.planes() {
|
||||||
panic!("out of bounds");
|
panic!("out of bounds");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user