r815: fixed a memory leak

This commit is contained in:
Heng Li 2018-07-15 22:11:32 -04:00
parent 830da7fa27
commit 395c8d678a
4 changed files with 15 additions and 8 deletions

View File

@ -48,11 +48,13 @@ void mm_idx_destroy(mm_idx_t *mi)
uint32_t i; uint32_t i;
if (mi == 0) return; if (mi == 0) return;
if (mi->h) kh_destroy(str, (khash_t(str)*)mi->h); if (mi->h) kh_destroy(str, (khash_t(str)*)mi->h);
if (mi->B) {
for (i = 0; i < 1U<<mi->b; ++i) { for (i = 0; i < 1U<<mi->b; ++i) {
free(mi->B[i].p); free(mi->B[i].p);
free(mi->B[i].a.a); free(mi->B[i].a.a);
kh_destroy(idx, (idxhash_t*)mi->B[i].h); kh_destroy(idx, (idxhash_t*)mi->B[i].h);
} }
}
if (!mi->km) { if (!mi->km) {
for (i = 0; i < mi->n_seq; ++i) for (i = 0; i < mi->n_seq; ++i)
free(mi->seq[i].name); free(mi->seq[i].name);

4
main.c
View File

@ -10,7 +10,7 @@
#include "getopt.h" #include "getopt.h"
#endif #endif
#define MM_VERSION "2.11-r814-dirty" #define MM_VERSION "2.11-r815-dirty"
#ifdef __linux__ #ifdef __linux__
#include <sys/resource.h> #include <sys/resource.h>
@ -330,7 +330,7 @@ int main(int argc, char *argv[])
} else { } else {
mm_write_sam_hdr(0, rg, MM_VERSION, argc, argv); mm_write_sam_hdr(0, rg, MM_VERSION, argc, argv);
if (opt.split_prefix == 0 && mm_verbose >= 2) if (opt.split_prefix == 0 && mm_verbose >= 2)
fprintf(stderr, "[WARNING]\033[1;31m For a multi-part index, no @SQ lines will be outputted.\033[0m\n"); fprintf(stderr, "[WARNING]\033[1;31m For a multi-part index, no @SQ lines will be outputted. Please use --split-prefix.\033[0m\n");
} }
} }
if (mm_verbose >= 3) if (mm_verbose >= 3)

4
map.c
View File

@ -659,6 +659,7 @@ int mm_split_merge(int n_segs, const char **fn, const mm_mapopt_t *opt, int n_sp
{ {
int i; int i;
pipeline_t pl; pipeline_t pl;
mm_idx_t *mi;
if (n_segs < 1 || n_split_idx < 1) return -1; if (n_segs < 1 || n_split_idx < 1) return -1;
memset(&pl, 0, sizeof(pipeline_t)); memset(&pl, 0, sizeof(pipeline_t));
pl.n_fp = n_segs; pl.n_fp = n_segs;
@ -670,7 +671,7 @@ int mm_split_merge(int n_segs, const char **fn, const mm_mapopt_t *opt, int n_sp
pl.n_parts = n_split_idx; pl.n_parts = n_split_idx;
pl.fp_parts = CALLOC(FILE*, pl.n_parts); pl.fp_parts = CALLOC(FILE*, pl.n_parts);
pl.rid_shift = CALLOC(uint32_t, pl.n_parts); pl.rid_shift = CALLOC(uint32_t, pl.n_parts);
pl.mi = mm_split_merge_prep(opt->split_prefix, n_split_idx, pl.fp_parts, pl.rid_shift); pl.mi = mi = mm_split_merge_prep(opt->split_prefix, n_split_idx, pl.fp_parts, pl.rid_shift);
if (pl.mi == 0) { if (pl.mi == 0) {
free(pl.fp_parts); free(pl.fp_parts);
free(pl.rid_shift); free(pl.rid_shift);
@ -687,6 +688,7 @@ int mm_split_merge(int n_segs, const char **fn, const mm_mapopt_t *opt, int n_sp
kt_pipeline(2, worker_pipeline, &pl, 3); kt_pipeline(2, worker_pipeline, &pl, 3);
free(pl.str.s); free(pl.str.s);
mm_idx_destroy(mi);
free(pl.rid_shift); free(pl.rid_shift);
for (i = 0; i < n_split_idx; ++i) for (i = 0; i < n_split_idx; ++i)
fclose(pl.fp_parts[i]); fclose(pl.fp_parts[i]);

View File

@ -239,7 +239,7 @@ Disable the long gap patching heuristic. When this option is applied, the
maximum alignment gap is mostly controlled by maximum alignment gap is mostly controlled by
.BR -r . .BR -r .
.TP .TP
.B --lj-min-ratio \ FLOAT .BI --lj-min-ratio \ FLOAT
Fraction of query sequence length required to bridge a long gap [0.5]. A Fraction of query sequence length required to bridge a long gap [0.5]. A
smaller value helps to recover longer gaps, at the cost of more false gaps. smaller value helps to recover longer gaps, at the cost of more false gaps.
.TP .TP
@ -252,6 +252,9 @@ applies a second round of chaining with a higher minimizer occurrence threshold
if no good chain is found. In addition, minimap2 attempts to patch gaps between if no good chain is found. In addition, minimap2 attempts to patch gaps between
seeds with ungapped alignment. seeds with ungapped alignment.
.TP .TP
.BI --split-prefix \ STR
Prefix to create temporary files. Typically used for a multi-part index.
.TP
.BR --frag = no | yes .BR --frag = no | yes
Whether to enable the fragment mode [no] Whether to enable the fragment mode [no]
.TP .TP