*: use is_null instead of == ptr::null()

This commit is contained in:
meh 2015-06-08 15:48:28 +02:00
parent ff1b880be6
commit d56ac34413
7 changed files with 23 additions and 25 deletions

View File

@ -74,7 +74,7 @@ impl Context {
pub fn codec(&self) -> Option<Codec> { pub fn codec(&self) -> Option<Codec> {
unsafe { unsafe {
if (*self.as_ptr()).codec == ptr::null() { if (*self.as_ptr()).codec.is_null() {
None None
} }
else { else {

View File

@ -16,7 +16,6 @@ pub mod check;
pub use self::check::Check; pub use self::check::Check;
use std::ffi::CString; use std::ffi::CString;
use std::ptr;
use std::slice::from_raw_parts; use std::slice::from_raw_parts;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
@ -136,7 +135,7 @@ pub fn find(id: Id) -> Option<Codec<'static>> {
unsafe { unsafe {
let ptr = avcodec_find_decoder(id.into()); let ptr = avcodec_find_decoder(id.into());
if ptr == ptr::null_mut() { if ptr.is_null() {
None None
} }
else { else {
@ -149,7 +148,7 @@ pub fn find_by_name(name: &str) -> Option<Codec<'static>> {
unsafe { unsafe {
let ptr = avcodec_find_decoder_by_name(CString::new(name).unwrap().as_ptr()); let ptr = avcodec_find_decoder_by_name(CString::new(name).unwrap().as_ptr());
if ptr == ptr::null_mut() { if ptr.is_null() {
None None
} }
else { else {

View File

@ -20,7 +20,6 @@ pub mod decision;
pub use self::decision::Decision; pub use self::decision::Decision;
use std::ffi::CString; use std::ffi::CString;
use std::ptr;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use libc::c_int; use libc::c_int;
@ -126,7 +125,7 @@ pub fn find(id: Id) -> Option<Codec<'static>> {
unsafe { unsafe {
let ptr = avcodec_find_encoder(id.into()); let ptr = avcodec_find_encoder(id.into());
if ptr == ptr::null_mut() { if ptr.is_null() {
None None
} }
else { else {
@ -139,7 +138,7 @@ pub fn find_by_name(name: &str) -> Option<Codec<'static>> {
unsafe { unsafe {
let ptr = avcodec_find_encoder_by_name(CString::new(name).unwrap().as_ptr()); let ptr = avcodec_find_encoder_by_name(CString::new(name).unwrap().as_ptr());
if ptr == ptr::null_mut() { if ptr.is_null() {
None None
} }
else { else {

View File

@ -13,7 +13,7 @@ impl Iterator for AudioIter {
unsafe { unsafe {
let ptr = av_input_audio_device_next(self.0); 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 None
} }
else { else {
@ -38,7 +38,7 @@ impl Iterator for VideoIter {
unsafe { unsafe {
let ptr = av_input_video_device_next(self.0); 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 None
} }
else { else {

View File

@ -13,7 +13,7 @@ impl Iterator for AudioIter {
unsafe { unsafe {
let ptr = av_output_audio_device_next(self.0); 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 None
} }
else { else {
@ -36,7 +36,7 @@ impl Iterator for VideoIter {
unsafe { unsafe {
let ptr = av_output_video_device_next(self.0); 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 None
} }
else { else {

View File

@ -59,7 +59,7 @@ impl Context {
unsafe { unsafe {
let ptr = av_format_get_video_codec(self.as_ptr()); let ptr = av_format_get_video_codec(self.as_ptr());
if ptr == ptr::null_mut() { if ptr.is_null() {
None None
} }
else { else {
@ -78,7 +78,7 @@ impl Context {
unsafe { unsafe {
let ptr = av_format_get_audio_codec(self.as_ptr()); let ptr = av_format_get_audio_codec(self.as_ptr());
if ptr == ptr::null_mut() { if ptr.is_null() {
None None
} }
else { else {
@ -97,7 +97,7 @@ impl Context {
unsafe { unsafe {
let ptr = av_format_get_subtitle_codec(self.as_ptr()); let ptr = av_format_get_subtitle_codec(self.as_ptr());
if ptr == ptr::null_mut() { if ptr.is_null() {
None None
} }
else { else {
@ -116,7 +116,7 @@ impl Context {
unsafe { unsafe {
let ptr = av_format_get_data_codec(self.as_ptr()); let ptr = av_format_get_data_codec(self.as_ptr());
if ptr == ptr::null_mut() { if ptr.is_null() {
None None
} }
else { else {

View File

@ -74,8 +74,8 @@ impl Input {
unsafe { unsafe {
let ptr = (*self.as_ptr()).extensions; let ptr = (*self.as_ptr()).extensions;
if ptr == ptr::null() { if ptr.is_null() {
vec!() Vec::new()
} }
else { else {
from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect() from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect()
@ -87,8 +87,8 @@ impl Input {
unsafe { unsafe {
let ptr = (*self.as_ptr()).mime_type; let ptr = (*self.as_ptr()).mime_type;
if ptr == ptr::null() { if ptr.is_null() {
vec!() Vec::new()
} }
else { else {
from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect() from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect()
@ -132,8 +132,8 @@ impl Output {
unsafe { unsafe {
let ptr = (*self.as_ptr()).extensions; let ptr = (*self.as_ptr()).extensions;
if ptr == ptr::null() { if ptr.is_null() {
vec!() Vec::new()
} }
else { else {
from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect() from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect()
@ -145,8 +145,8 @@ impl Output {
unsafe { unsafe {
let ptr = (*self.as_ptr()).mime_type; let ptr = (*self.as_ptr()).mime_type;
if ptr == ptr::null() { if ptr.is_null() {
vec!() Vec::new()
} }
else { else {
from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect() from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()).split(',').collect()
@ -180,7 +180,7 @@ impl Iterator for FormatIter {
0 => { 0 => {
let ptr = av_iformat_next(self.input); 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.step = 1;
self.next() self.next()
@ -195,7 +195,7 @@ impl Iterator for FormatIter {
1 => { 1 => {
let ptr = av_oformat_next(self.output); 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.step = 2;
self.next() self.next()