Skip to content

Commit

Permalink
avoid unnecessary memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Heng Li committed Oct 5, 2011
1 parent 901a671 commit e7c0166
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions correct.c
Expand Up @@ -207,15 +207,17 @@ static void ec_fix(const rld_t *e, const errcorr_t *ec, int start, int step)
for (i = start<<1, sum = 0; i < e->mcnt[1]; i += step<<1) {
a.n = 0;
k = fm_retrieve(e, i + 1, &str);
assert(k >= 0 && k < e->mcnt[1]);
ec_get_changes(ec, k, &a);
for (j = 0; j < a.n; ++j) // lift to the forward strand
a.a[j] = (str.l - 1 - (a.a[j]&0xffff)) | ((3 - (a.a[j]>>16&3)) << 16);
k = fm_retrieve(e, i, &str);
seq_reverse(str.l, (uint8_t*)str.s);
assert(k >= 0 && k < e->mcnt[1]);
seq_reverse(str.l, (uint8_t*)str.s); // str.s is reversed (but not complemented)
ec_get_changes(ec, k, &a);
for (j = 0; j < a.n; ++j) { // apply the changes
str.s[a.a[j]&0xffff] = (a.a[j]>>16&3) + 1;
assert((a.a[j]&0xffff) < str.l);
str.s[a.a[j]&0xffff] = (a.a[j]>>16&3) + 1;
}
kputc('>', &out); kputl((long)(i>>1), &out); kputc('\n', &out);
ks_resize(&out, out.l + str.l + 2);
Expand Down Expand Up @@ -293,7 +295,7 @@ int fm6_ec_correct(const rld_t *e, const fmecopt_t *opt, int n_threads)
}
// initialize "ec" and "tid"
ec = calloc(1, sizeof(errcorr_t));
ec->n = (e->mcnt[0] + B_MASK) >> B_SHIFT;
ec->n = (e->mcnt[1] + B_MASK) >> B_SHIFT;
ec->b = calloc(ec->n, sizeof(vec32_t));
ec->lock = calloc(ec->n, 1);
avg_bucket_size = (int64_t)((e->mcnt[0] - e->mcnt[1]) * opt->err / ec->n + .499);
Expand Down
2 changes: 1 addition & 1 deletion fermi.h
Expand Up @@ -4,7 +4,7 @@
#include <stdint.h>
#include <stdlib.h>

#define FERMI_VERSION "0.0-dev (r277)"
#define FERMI_VERSION "0.0-dev (r282)"

#define FM_MASK30 0x3fffffff

Expand Down
2 changes: 1 addition & 1 deletion kstring.h
Expand Up @@ -144,7 +144,7 @@ static inline int kputuw(unsigned c, kstring_t *s)

static inline int kputl(long c, kstring_t *s)
{
char buf[16];
char buf[32];
long l, x;
if (c == 0) return kputc('0', s);
for (l = 0, x = c < 0? -c : c; x > 0; x /= 10) buf[l++] = x%10 + '0';
Expand Down

0 comments on commit e7c0166

Please sign in to comment.