fixed memory leaks

though some of them are not really leaks when kalloc is in use.
This commit is contained in:
Heng Li 2017-06-06 21:45:55 -04:00
parent e6adb673f9
commit c1c946aa67
3 changed files with 8 additions and 2 deletions

View File

@ -63,7 +63,10 @@ int mm_chain_dp(int max_dist, int bw, int max_skip, int min_sc, int n, mm128_t *
for (i = n_u = 0; i < n; ++i)
if (t[i] == 0 && f[i] >= min_sc)
++n_u;
if (n_u == 0) return 0;
if (n_u == 0) {
kfree(km, f); kfree(km, p); kfree(km, t);
return 0;
}
u = (uint64_t*)kmalloc(km, n_u * 8);
for (i = n_u = 0; i < n; ++i)
if (t[i] == 0 && f[i] >= min_sc)
@ -100,7 +103,7 @@ int mm_chain_dp(int max_dist, int bw, int max_skip, int min_sc, int n, mm128_t *
kfree(km, f); kfree(km, p); kfree(km, t);
// write the result to _a_
b = kmalloc(km, n_v * sizeof(mm128_t));
b = (mm128_t*)kmalloc(km, n_v * sizeof(mm128_t));
for (i = 0, k = 0; i < n_u; ++i)
for (j = 0; j < (int32_t)u[i]; ++j)
b[k] = a[v[k]], ++k;

2
map.c
View File

@ -60,6 +60,8 @@ mm_tbuf_t *mm_tbuf_init(void)
void mm_tbuf_destroy(mm_tbuf_t *b)
{
if (b == 0) return;
kfree(b->km, b->mini.a);
sdust_buf_destroy(b->sdb);
km_destroy(b->km_fixed);
km_destroy(b->km);
free(b);

View File

@ -62,6 +62,7 @@ sdust_buf_t *sdust_buf_init(void *km)
void sdust_buf_destroy(sdust_buf_t *buf)
{
if (buf == 0) return;
kdq_destroy(int, buf->w);
kfree(buf->km, buf->P.a); kfree(buf->km, buf->res.a); kfree(buf->km, buf);
}