X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bam_lpileup.c;h=1562170e9159e8b53f2d65d7c87e4a59e8acecac;hb=1a23a35867ee992dcffcf3d17df2b7d41732f33b;hp=368028766842db8b9b71c82c4fc85a2eb3a87092;hpb=635998cfe030da5f3dbec42a6daa3ca82fa5c871;p=samtools.git diff --git a/bam_lpileup.c b/bam_lpileup.c index 3680287..1562170 100644 --- a/bam_lpileup.c +++ b/bam_lpileup.c @@ -102,7 +102,7 @@ static int tview_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl } else tv->cur_level[i] = ++tv->max_level; } else { tv->cur_level[i] = tv->pre_level[l++]; - if (p->qpos == p->b->core.l_qseq - 1) { // then return a free slot + if (p->is_tail) { // then return a free slot tv->tail->level = tv->cur_level[i]; tv->tail->next = mp_alloc(tv->mp); tv->tail = tv->tail->next; @@ -150,6 +150,16 @@ static int tview_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl tv->pre_level[l++] = tv->pre_level[i]; } tv->n_pre = l; +/* + fprintf(stderr, "%d\t", pos+1); + for (i = 0; i < n; ++i) { + const bam_pileup1_t *p = pl + i; + if (p->is_head) fprintf(stderr, "^"); + if (p->is_tail) fprintf(stderr, "$"); + fprintf(stderr, "%d,", p->level); + } + fprintf(stderr, "\n"); +*/ return 0; } @@ -167,11 +177,17 @@ bam_lplbuf_t *bam_lplbuf_init(bam_pileup_f func, void *data) void bam_lplbuf_destroy(bam_lplbuf_t *tv) { - mp_free(tv->mp, tv->head); - mp_destroy(tv->mp); + freenode_t *p, *q; free(tv->cur_level); free(tv->pre_level); bam_plbuf_destroy(tv->plbuf); free(tv->aux); + for (p = tv->head; p->next;) { + q = p->next; + mp_free(tv->mp, p); p = q; + } + mp_free(tv->mp, p); + assert(tv->mp->cnt == 0); + mp_destroy(tv->mp); free(tv); }