Skip to content

Commit

Permalink
Use drop to fix compiler warnings (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garvys authored Aug 21, 2023
1 parent 9acc243 commit 7a50cfd
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 33 deletions.
8 changes: 2 additions & 6 deletions rustfst-ffi/src/algorithms/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ pub extern "C" fn fst_matcher_config_destroy(ptr: *mut CMatcherConfig) -> RUSTFS
return Ok(());
}

unsafe {
Box::from_raw(ptr);
}
unsafe { drop(Box::from_raw(ptr)) }
Ok(())
})
}
Expand All @@ -282,9 +280,7 @@ pub extern "C" fn fst_compose_config_destroy(ptr: *mut CComposeConfig) -> RUSTFS
return Ok(());
}

unsafe {
Box::from_raw(ptr);
}
unsafe { drop(Box::from_raw(ptr)) }
Ok(())
})
}
Expand Down
4 changes: 1 addition & 3 deletions rustfst-ffi/src/fst/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,7 @@ pub fn fst_destroy(fst_ptr: *mut CFst) -> RUSTFST_FFI_RESULT {
return Ok(());
}

unsafe {
Box::from_raw(fst_ptr);
}
unsafe { drop(Box::from_raw(fst_ptr)) }
Ok(())
})
}
12 changes: 3 additions & 9 deletions rustfst-ffi/src/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ pub extern "C" fn trs_iterator_destroy(iter_ptr: *mut CTrsIterator) -> RUSTFST_F
return Ok(());
}

unsafe {
Box::from_raw(iter_ptr);
}
unsafe { drop(Box::from_raw(iter_ptr)) }
Ok(())
})
}
Expand Down Expand Up @@ -273,9 +271,7 @@ pub extern "C" fn mut_trs_iterator_destroy(iter_ptr: *mut CMutTrsIterator) -> RU
return Ok(());
}

unsafe {
Box::from_raw(iter_ptr);
}
unsafe { drop(Box::from_raw(iter_ptr)) }
Ok(())
})
}
Expand Down Expand Up @@ -332,9 +328,7 @@ pub extern "C" fn state_iterator_destroy(iter_ptr: *mut CStateIterator) -> RUSTF
return Ok(());
}

unsafe {
Box::from_raw(iter_ptr);
}
unsafe { drop(Box::from_raw(iter_ptr)) }
Ok(())
})
}
4 changes: 1 addition & 3 deletions rustfst-ffi/src/string_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ pub extern "C" fn string_path_destroy(iter_ptr: *mut CStringPath) -> RUSTFST_FFI
return Ok(());
}

unsafe {
Box::from_raw(iter_ptr);
}
unsafe { drop(Box::from_raw(iter_ptr)) }
Ok(())
})
}
Expand Down
4 changes: 1 addition & 3 deletions rustfst-ffi/src/string_paths_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ pub extern "C" fn string_paths_iterator_destroy(
return Ok(());
}

unsafe {
Box::from_raw(iter_ptr);
}
unsafe { drop(Box::from_raw(iter_ptr)) }
Ok(())
})
}
4 changes: 1 addition & 3 deletions rustfst-ffi/src/symbol_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ pub extern "C" fn symt_destroy(symt_ptr: *mut CSymbolTable) -> RUSTFST_FFI_RESUL
return Ok(());
}

unsafe {
Box::from_raw(symt_ptr);
}
unsafe { drop(Box::from_raw(symt_ptr)) }
Ok(())
})
}
4 changes: 1 addition & 3 deletions rustfst-ffi/src/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ pub extern "C" fn tr_delete(tr_ptr: *mut CTr) -> RUSTFST_FFI_RESULT {
return Ok(());
}

unsafe {
Box::from_raw(tr_ptr);
}
unsafe { drop(Box::from_raw(tr_ptr)) }
Ok(())
})
}
4 changes: 1 addition & 3 deletions rustfst-ffi/src/trs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ pub extern "C" fn trs_vec_delete(trs_ptr: *mut CTrs) -> RUSTFST_FFI_RESULT {
return Ok(());
}

unsafe {
Box::from_raw(trs_ptr);
}
unsafe { drop(Box::from_raw(trs_ptr)) }
Ok(())
})
}

0 comments on commit 7a50cfd

Please sign in to comment.