r1089: fixed an unusual memory leak (#749)

This is more apparent when there are many candidate chains. Although only a
small numbers of them are extended, they are still occupying memory. A
realloc() solves this problem. This is a long existiing issue.
This commit is contained in:
Heng Li 2021-08-04 17:07:00 -04:00
parent 629c11728e
commit 2392e54fe2
2 changed files with 2 additions and 1 deletions

2
main.c
View File

@ -7,7 +7,7 @@
#include "mmpriv.h"
#include "ketopt.h"
#define MM_VERSION "2.21-dev-r1087-dirty"
#define MM_VERSION "2.21-dev-r1089-dirty"
#ifdef __linux__
#include <sys/resource.h>

1
map.c
View File

@ -336,6 +336,7 @@ void mm_map_frag(const mm_idx_t *mi, int n_segs, const int *qlens, const char **
if (n_segs == 1) { // uni-segment
regs0 = align_regs(opt, mi, b->km, qlens[0], seqs[0], &n_regs0, regs0, a);
regs0 = (mm_reg1_t*)realloc(regs0, sizeof(*regs0) * n_regs0);
mm_set_mapq(b->km, n_regs0, regs0, opt->min_chain_score, opt->a, rep_len, is_sr);
n_regs[0] = n_regs0, regs[0] = regs0;
} else { // multi-segment