Skip to content

Commit

Permalink
Use ptr::null_mut instead of 0 as *mut (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e authored and seanmonstar committed Aug 30, 2019
1 parent 3a8994b commit 434d29c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ fn get_num_cpus() -> usize {
target_os = "dragonfly",
target_os = "netbsd"))]
fn get_num_cpus() -> usize {
use std::ptr;

let mut cpus: libc::c_uint = 0;
let mut cpus_size = std::mem::size_of_val(&cpus);

Expand All @@ -280,7 +282,7 @@ fn get_num_cpus() -> usize {
2,
&mut cpus as *mut _ as *mut _,
&mut cpus_size as *mut _ as *mut _,
0 as *mut _,
ptr::null_mut(),
0);
}
if cpus < 1 {
Expand All @@ -292,6 +294,8 @@ fn get_num_cpus() -> usize {

#[cfg(target_os = "openbsd")]
fn get_num_cpus() -> usize {
use std::ptr;

let mut cpus: libc::c_uint = 0;
let mut cpus_size = std::mem::size_of_val(&cpus);
let mut mib = [libc::CTL_HW, libc::HW_NCPU, 0, 0];
Expand All @@ -301,7 +305,7 @@ fn get_num_cpus() -> usize {
2,
&mut cpus as *mut _ as *mut _,
&mut cpus_size as *mut _ as *mut _,
0 as *mut _,
ptr::null_mut(),
0);
}
if cpus < 1 {
Expand Down

0 comments on commit 434d29c

Please sign in to comment.