Skip to content

Commit 990dde6

Browse files
zmwangxmeh
authored andcommitted
Fix clippy::transmute_ptr_to_ptr
1 parent 808a92f commit 990dde6

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

src/util/format/sample.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use std::{
22
ffi::{CStr, CString},
3-
mem,
43
ops::Index,
54
ptr, slice,
65
str::from_utf8_unchecked,
76
};
87

9-
use libc::c_int;
8+
use libc::{c_int, c_void};
109

1110
use crate::ffi::{AVSampleFormat::*, *};
1211

@@ -208,7 +207,7 @@ impl Clone for Buffer {
208207
unsafe {
209208
av_samples_copy(
210209
self.buffer,
211-
mem::transmute(source.buffer),
210+
source.buffer as *const *mut u8,
212211
0,
213212
0,
214213
source.samples as c_int,
@@ -223,7 +222,7 @@ impl Drop for Buffer {
223222
#[inline]
224223
fn drop(&mut self) {
225224
unsafe {
226-
av_freep(mem::transmute(self.buffer));
225+
av_freep(self.buffer as *mut c_void);
227226
}
228227
}
229228
}

src/util/frame/audio.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl Audio {
149149
panic!("unsupported type");
150150
}
151151

152-
unsafe { slice::from_raw_parts(mem::transmute((*self.as_ptr()).data[index]), self.samples()) }
152+
unsafe { slice::from_raw_parts((*self.as_ptr()).data[index] as *const T, self.samples()) }
153153
}
154154

155155
#[inline]
@@ -162,12 +162,7 @@ impl Audio {
162162
panic!("unsupported type");
163163
}
164164

165-
unsafe {
166-
slice::from_raw_parts_mut(
167-
mem::transmute((*self.as_mut_ptr()).data[index]),
168-
self.samples(),
169-
)
170-
}
165+
unsafe { slice::from_raw_parts_mut((*self.as_mut_ptr()).data[index] as *mut T, self.samples()) }
171166
}
172167

173168
#[inline]

src/util/frame/video.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ impl Video {
267267

268268
unsafe {
269269
slice::from_raw_parts(
270-
mem::transmute((*self.as_ptr()).data[index]),
270+
(*self.as_ptr()).data[index] as *const T,
271271
self.stride(index) * self.plane_height(index) as usize / mem::size_of::<T>(),
272272
)
273273
}
@@ -285,7 +285,7 @@ impl Video {
285285

286286
unsafe {
287287
slice::from_raw_parts_mut(
288-
mem::transmute((*self.as_mut_ptr()).data[index]),
288+
(*self.as_mut_ptr()).data[index] as *mut T,
289289
self.stride(index) * self.plane_height(index) as usize / mem::size_of::<T>(),
290290
)
291291
}

0 commit comments

Comments
 (0)