Skip to content

Commit

Permalink
bam::Record:new should return a valid record
Browse files Browse the repository at this point in the history
  • Loading branch information
nh13 committed Jun 17, 2022
1 parent b130634 commit 4db8850
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/bam/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,19 @@ fn extranul_from_qname(qname: &[u8]) -> usize {
impl Record {
/// Create an empty BAM record.
pub fn new() -> Self {
Record {
let record = Record {
inner: unsafe { MaybeUninit::zeroed().assume_init() },
own: true,
cigar: None,
header: None,
}
// Developer note: these are needed so the returned record is properly
// initialized as unmapped.
record.set_tid(-1);
record.set_pos(-1);
record.set_mpos(-1);
record.set_mtid(-1);
record
}

pub fn from_inner(from: *mut htslib::bam1_t) -> Self {
Expand Down

0 comments on commit 4db8850

Please sign in to comment.