r129: fixed memory leak caused by qualities

This commit is contained in:
Heng Li
2017-06-30 23:48:00 -04:00
parent 10910b72d1
commit 41efd03d7a
6 changed files with 24 additions and 8 deletions
+2 -2
View File
@@ -32,7 +32,7 @@ void bseq_close(bseq_file_t *fp)
free(fp);
}
bseq1_t *bseq_read(bseq_file_t *fp, int chunk_size, int *n_)
bseq1_t *bseq_read(bseq_file_t *fp, int chunk_size, int with_qual, int *n_)
{
int size = 0, m, n;
bseq1_t *seqs;
@@ -48,7 +48,7 @@ bseq1_t *bseq_read(bseq_file_t *fp, int chunk_size, int *n_)
s = &seqs[n];
s->name = strdup(ks->name.s);
s->seq = strdup(ks->seq.s);
s->qual = ks->qual.l? strdup(ks->qual.s) : 0;
s->qual = with_qual && ks->qual.l? strdup(ks->qual.s) : 0;
s->l_seq = ks->seq.l;
size += seqs[n++].l_seq;
if (size >= chunk_size) break;