Skip to content

Commit 33cc670

Browse files
authored
refactor: remove unsafe label from fn that is now safe (#552)
1 parent 22391dc commit 33cc670

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

src/table_collection.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,7 @@ impl TableCollection {
8989
})
9090
}
9191

92-
/// # Safety
93-
///
94-
/// It is possible that the mbox's inner pointer has not be run through
95-
/// tsk_table_collection_init, meaning that it is in an uninitialized state.
96-
/// Or, it may be initialized and about to be used in a part of the C API
97-
/// requiring an uninitialized table collection.
98-
/// Consult the C API docs before using!
99-
pub(crate) unsafe fn new_from_ll(lltables: LLTableCollection) -> Result<Self, TskitError> {
92+
pub(crate) fn new_from_ll(lltables: LLTableCollection) -> Result<Self, TskitError> {
10093
let mut inner = lltables;
10194
let views = crate::table_views::TableViews::new_from_ll_table_collection(&mut inner)?;
10295
Ok(Self {
@@ -748,10 +741,7 @@ impl TableCollection {
748741
/// Return a "deep" copy of the tables.
749742
pub fn deepcopy(&self) -> Result<TableCollection, TskitError> {
750743
let (rv, inner) = self.inner.copy();
751-
752-
// SAFETY: we just initialized it.
753-
// The C API doesn't free NULL pointers.
754-
let tables = unsafe { TableCollection::new_from_ll(inner) }?;
744+
let tables = TableCollection::new_from_ll(inner)?;
755745
handle_tsk_return_value!(rv, tables)
756746
}
757747

src/trees/treeseq.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ impl TreeSequence {
179179
ll_bindings::tsk_table_collection_copy((*self.as_ptr()).tables, inner.as_mut_ptr(), 0)
180180
};
181181

182-
// SAFETY: we just initialized it.
183-
// The C API doesn't free NULL pointers.
184-
handle_tsk_return_value!(rv, unsafe { TableCollection::new_from_ll(inner)? })
182+
handle_tsk_return_value!(rv, TableCollection::new_from_ll(inner)?)
185183
}
186184

187185
/// Create an iterator over trees.

0 commit comments

Comments
 (0)