Skip to content

Commit 4424468

Browse files
BickfordAdaviesrob
andauthored
Update docs: Iterate through bam1_t records (PR #1381)
I think this needs to iterate through the records, as it is just passing the index right now. Ensures 'recs' was allocated when cleaning up. Co-authored-by: Rob Davies <rmd+git@sanger.ac.uk>
1 parent 4289991 commit 4424468

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

htslib/sam.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -944,10 +944,12 @@ void bam_destroy1(bam1_t *b);
944944
// ... use data ...
945945
946946
cleanup:
947-
for (size_t i = 0; i < nrecs; i++)
948-
bam_destroy1(i);
947+
if (recs) {
948+
for (size_t i = 0; i < nrecs; i++)
949+
bam_destroy1(&recs[i]);
950+
free(recs);
951+
}
949952
free(buffer);
950-
free(recs);
951953
952954
\endcode
953955
*/

0 commit comments

Comments
 (0)