diff --git a/src/codec/context.rs b/src/codec/context.rs index 4679939..f6387b7 100644 --- a/src/codec/context.rs +++ b/src/codec/context.rs @@ -74,7 +74,7 @@ impl Context { pub fn codec(&self) -> Option { unsafe { - if (*self.as_ptr()).codec == ptr::null() { + if (*self.as_ptr()).codec.is_null() { None } else { diff --git a/src/codec/decoder/mod.rs b/src/codec/decoder/mod.rs index 016a6d0..4916033 100644 --- a/src/codec/decoder/mod.rs +++ b/src/codec/decoder/mod.rs @@ -16,7 +16,6 @@ pub mod check; pub use self::check::Check; use std::ffi::CString; -use std::ptr; use std::slice::from_raw_parts; use std::ops::{Deref, DerefMut}; @@ -136,7 +135,7 @@ pub fn find(id: Id) -> Option> { unsafe { let ptr = avcodec_find_decoder(id.into()); - if ptr == ptr::null_mut() { + if ptr.is_null() { None } else { @@ -149,7 +148,7 @@ pub fn find_by_name(name: &str) -> Option> { unsafe { let ptr = avcodec_find_decoder_by_name(CString::new(name).unwrap().as_ptr()); - if ptr == ptr::null_mut() { + if ptr.is_null() { None } else { diff --git a/src/codec/encoder/mod.rs b/src/codec/encoder/mod.rs index 4bb416f..c30e6dc 100644 --- a/src/codec/encoder/mod.rs +++ b/src/codec/encoder/mod.rs @@ -20,7 +20,6 @@ pub mod decision; pub use self::decision::Decision; use std::ffi::CString; -use std::ptr; use std::ops::{Deref, DerefMut}; use libc::c_int; @@ -126,7 +125,7 @@ pub fn find(id: Id) -> Option> { unsafe { let ptr = avcodec_find_encoder(id.into()); - if ptr == ptr::null_mut() { + if ptr.is_null() { None } else { @@ -139,7 +138,7 @@ pub fn find_by_name(name: &str) -> Option> { unsafe { let ptr = avcodec_find_encoder_by_name(CString::new(name).unwrap().as_ptr()); - if ptr == ptr::null_mut() { + if ptr.is_null() { None } else { diff --git a/src/device/input.rs b/src/device/input.rs index bfb719a..43e4fdf 100644 --- a/src/device/input.rs +++ b/src/device/input.rs @@ -13,7 +13,7 @@ impl Iterator for AudioIter { unsafe { let ptr = av_input_audio_device_next(self.0); - if ptr == ptr::null_mut() && self.0 != ptr::null_mut() { + if ptr.is_null() && !self.0.is_null() { None } else { @@ -38,7 +38,7 @@ impl Iterator for VideoIter { unsafe { let ptr = av_input_video_device_next(self.0); - if ptr == ptr::null_mut() && self.0 != ptr::null_mut() { + if ptr.is_null() && !self.0.is_null() { None } else { diff --git a/src/device/output.rs b/src/device/output.rs index 029caab..64d71cc 100644 --- a/src/device/output.rs +++ b/src/device/output.rs @@ -13,7 +13,7 @@ impl Iterator for AudioIter { unsafe { let ptr = av_output_audio_device_next(self.0); - if ptr == ptr::null_mut() && self.0 != ptr::null_mut() { + if ptr.is_null() && !self.0.is_null() { None } else { @@ -36,7 +36,7 @@ impl Iterator for VideoIter { unsafe { let ptr = av_output_video_device_next(self.0); - if ptr == ptr::null_mut() && self.0 != ptr::null_mut() { + if ptr.is_null() && !self.0.is_null() { None } else { diff --git a/src/format/context.rs b/src/format/context.rs index 2bcaa5d..b9eb7b7 100644 --- a/src/format/context.rs +++ b/src/format/context.rs @@ -59,7 +59,7 @@ impl Context { unsafe { let ptr = av_format_get_video_codec(self.as_ptr()); - if ptr == ptr::null_mut() { + if ptr.is_null() { None } else { @@ -78,7 +78,7 @@ impl Context { unsafe { let ptr = av_format_get_audio_codec(self.as_ptr()); - if ptr == ptr::null_mut() { + if ptr.is_null() { None } else { @@ -97,7 +97,7 @@ impl Context { unsafe { let ptr = av_format_get_subtitle_codec(self.as_ptr()); - if ptr == ptr::null_mut() { + if ptr.is_null() { None } else { @@ -116,7 +116,7 @@ impl Context { unsafe { let ptr = av_format_get_data_codec(self.as_ptr()); - if ptr == ptr::null_mut() { + if ptr.is_null() { None } else { diff --git a/src/format/format.rs b/src/format/format.rs index 44832b7..ab42b4f 100644 --- a/src/format/format.rs +++ b/src/format/format.rs @@ -74,8 +74,8 @@ impl Input { unsafe { let ptr = (*self.as_ptr()).extensions; - if ptr == ptr::null() { - vec!() + if ptr.is_null() { + Vec::new() } else { from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect() @@ -87,8 +87,8 @@ impl Input { unsafe { let ptr = (*self.as_ptr()).mime_type; - if ptr == ptr::null() { - vec!() + if ptr.is_null() { + Vec::new() } else { from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect() @@ -132,8 +132,8 @@ impl Output { unsafe { let ptr = (*self.as_ptr()).extensions; - if ptr == ptr::null() { - vec!() + if ptr.is_null() { + Vec::new() } else { from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect() @@ -145,8 +145,8 @@ impl Output { unsafe { let ptr = (*self.as_ptr()).mime_type; - if ptr == ptr::null() { - vec!() + if ptr.is_null() { + Vec::new() } else { from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect() @@ -180,7 +180,7 @@ impl Iterator for FormatIter { 0 => { let ptr = av_iformat_next(self.input); - if ptr == ptr::null_mut() && self.input != ptr::null_mut() { + if ptr.is_null() && !self.input.is_null() { self.step = 1; self.next() @@ -195,7 +195,7 @@ impl Iterator for FormatIter { 1 => { let ptr = av_oformat_next(self.output); - if ptr == ptr::null_mut() && self.output != ptr::null_mut() { + if ptr.is_null() && !self.output.is_null() { self.step = 2; self.next()