mirror of
https://github.com/dnlbauer/xdrfile.git
synced 2026-09-11 22:55:31 +00:00
Removed pointer casts from lib.rs
This commit is contained in:
@@ -29,8 +29,8 @@ extern "C" {
|
|||||||
natoms: ::std::os::raw::c_int,
|
natoms: ::std::os::raw::c_int,
|
||||||
step: ::std::os::raw::c_int,
|
step: ::std::os::raw::c_int,
|
||||||
time: ::std::os::raw::c_float,
|
time: ::std::os::raw::c_float,
|
||||||
box_vec: *mut Matrix,
|
box_vec: *const Matrix,
|
||||||
x: *mut Rvec,
|
x: *const Rvec,
|
||||||
prec: ::std::os::raw::c_float,
|
prec: ::std::os::raw::c_float,
|
||||||
) -> ::std::os::raw::c_int;
|
) -> ::std::os::raw::c_int;
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/lib.rs
12
src/lib.rs
@@ -289,8 +289,8 @@ impl Trajectory for XTCTrajectory {
|
|||||||
to_c_int(frame.len(), ErrorTask::Write)?,
|
to_c_int(frame.len(), ErrorTask::Write)?,
|
||||||
to_c_int(frame.step, ErrorTask::Write)?,
|
to_c_int(frame.step, ErrorTask::Write)?,
|
||||||
frame.time,
|
frame.time,
|
||||||
frame.box_vector.as_ptr() as *mut [[f32; 3]; 3],
|
&frame.box_vector,
|
||||||
frame.coords[..].as_ptr() as *mut [f32; 3],
|
frame.coords.as_ptr(),
|
||||||
1000.0,
|
1000.0,
|
||||||
);
|
);
|
||||||
if let Some(err) = check_code(code, ErrorTask::Write) {
|
if let Some(err) = check_code(code, ErrorTask::Write) {
|
||||||
@@ -320,7 +320,7 @@ impl Trajectory for XTCTrajectory {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let path = path_to_cstring(&self.handle.path)?;
|
let path = path_to_cstring(&self.handle.path)?;
|
||||||
let path_p = path.into_raw();
|
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
|
// Reconstitute the CString so it is deallocated correctly
|
||||||
let _ = CString::from_raw(path_p);
|
let _ = CString::from_raw(path_p);
|
||||||
|
|
||||||
@@ -420,8 +420,8 @@ impl Trajectory for TRRTrajectory {
|
|||||||
to_c_int(frame.step, ErrorTask::Write)?,
|
to_c_int(frame.step, ErrorTask::Write)?,
|
||||||
frame.time,
|
frame.time,
|
||||||
0.0,
|
0.0,
|
||||||
frame.box_vector.as_ptr() as *mut [[f32; 3]; 3],
|
&frame.box_vector,
|
||||||
frame.coords[..].as_ptr() as *mut [f32; 3],
|
frame.coords[..].as_ptr(),
|
||||||
std::ptr::null_mut(),
|
std::ptr::null_mut(),
|
||||||
std::ptr::null_mut(),
|
std::ptr::null_mut(),
|
||||||
);
|
);
|
||||||
@@ -451,7 +451,7 @@ impl Trajectory for TRRTrajectory {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let path = path_to_cstring(&self.handle.path)?;
|
let path = path_to_cstring(&self.handle.path)?;
|
||||||
let path_p = path.into_raw();
|
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
|
// Reconstitute the CString so it is deallocated correctly
|
||||||
let _ = CString::from_raw(path_p);
|
let _ = CString::from_raw(path_p);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user