Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/trees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,10 @@ impl TreeSequence {
handle_tsk_return_value!(rv, treeseq)
}

fn new_uninit() -> Self {
Self::wrap()
}

/// Dump the tree sequence to file.
///
/// # Note
Expand Down Expand Up @@ -1190,12 +1194,9 @@ impl TreeSequence {
options: O,
idmap: bool,
) -> Result<(Self, Option<Vec<NodeId>>), TskitError> {
let mut tables = TableCollection::new(unsafe { (*(*self.inner).tables).sequence_length })?;
match tables.build_index() {
Ok(_) => (),
Err(e) => return Err(e),
}
let mut ts = tables.tree_sequence(TreeSequenceFlags::default())?;
// The output is an UNINITIALIZED treeseq,
// else we leak memory.
let mut ts = Self::new_uninit();
let mut output_node_map: Vec<NodeId> = vec![];
if idmap {
output_node_map.resize(usize::try_from(self.nodes().num_rows())?, NodeId::NULL);
Expand Down