From 9a4f27aeb72c9a730390b55f15631ebbaa8068a5 Mon Sep 17 00:00:00 2001 From: Josh Mitchell Date: Sun, 15 Nov 2020 17:21:49 +1100 Subject: [PATCH] Removed pointer casts from lib.rs --- src/c_abi/xdrfile_xtc.rs | 4 ++-- src/lib.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/c_abi/xdrfile_xtc.rs b/src/c_abi/xdrfile_xtc.rs index a002604..d59e8bf 100644 --- a/src/c_abi/xdrfile_xtc.rs +++ b/src/c_abi/xdrfile_xtc.rs @@ -29,8 +29,8 @@ extern "C" { natoms: ::std::os::raw::c_int, step: ::std::os::raw::c_int, time: ::std::os::raw::c_float, - box_vec: *mut Matrix, - x: *mut Rvec, + box_vec: *const Matrix, + x: *const Rvec, prec: ::std::os::raw::c_float, ) -> ::std::os::raw::c_int; } diff --git a/src/lib.rs b/src/lib.rs index d08332d..2bc12da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -289,8 +289,8 @@ impl Trajectory for XTCTrajectory { to_c_int(frame.len(), ErrorTask::Write)?, to_c_int(frame.step, ErrorTask::Write)?, frame.time, - frame.box_vector.as_ptr() as *mut [[f32; 3]; 3], - frame.coords[..].as_ptr() as *mut [f32; 3], + &frame.box_vector, + frame.coords.as_ptr(), 1000.0, ); if let Some(err) = check_code(code, ErrorTask::Write) { @@ -320,7 +320,7 @@ impl Trajectory for XTCTrajectory { unsafe { let path = path_to_cstring(&self.handle.path)?; let path_p = path.into_raw(); - let code = xdrfile_xtc::read_xtc_natoms(path_p, &mut num_atoms as *const c_int); + let code = xdrfile_xtc::read_xtc_natoms(path_p, &mut num_atoms); // Reconstitute the CString so it is deallocated correctly let _ = CString::from_raw(path_p); @@ -420,8 +420,8 @@ impl Trajectory for TRRTrajectory { to_c_int(frame.step, ErrorTask::Write)?, frame.time, 0.0, - frame.box_vector.as_ptr() as *mut [[f32; 3]; 3], - frame.coords[..].as_ptr() as *mut [f32; 3], + &frame.box_vector, + frame.coords[..].as_ptr(), std::ptr::null_mut(), std::ptr::null_mut(), ); @@ -451,7 +451,7 @@ impl Trajectory for TRRTrajectory { unsafe { let path = path_to_cstring(&self.handle.path)?; let path_p = path.into_raw(); - let code = xdrfile_trr::read_trr_natoms(path_p, &mut num_atoms as *const c_int); + let code = xdrfile_trr::read_trr_natoms(path_p, &mut num_atoms); // Reconstitute the CString so it is deallocated correctly let _ = CString::from_raw(path_p);