diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2014-04-14 14:01:58 -0400 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2014-04-14 14:01:58 -0400 |
commit | a50bc3833b9c8eb8a510934b3fc4e3b3eb38dec0 (patch) | |
tree | 496ba6db47b195e647d30411b94ab4497e67ca4b | |
parent | 75b61da3ab27712bd96690b1e52a4c3c12788d49 (diff) |
fix malloc in locations
-rw-r--r-- | kmer_locations.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/kmer_locations.c b/kmer_locations.c index a6a2dc9..23d0998 100644 --- a/kmer_locations.c +++ b/kmer_locations.c @@ -215,16 +215,14 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } - labeled_mers = (char**) malloc(sizeof(char **)); + labeled_mers = (char**) malloc(sizeof(char **) * num_desired_indicies); check_null_ptr(labeled_mers, NULL); for(j = 0; j < num_desired_indicies; j++) { labeled_mers[j] = index_to_kmer(desired_indicies[j], kmer); } } - unsigned long long global_position = 0; - while ((read = getdelim(&line, &len, '>', fh)) != -1) { size_t k = 0; @@ -240,9 +238,6 @@ int main(int argc, char **argv) { // strip out all other newlines to handle multiline sequences size_t seq_length = strnstrip(seq, '\n', strlen(seq)); - if(seq[seq_length - 1] == '>') - seq_length --; - for(k = 0; k < seq_length; k++) { seq[k] = alpha[(int)seq[k]]; } @@ -273,6 +268,7 @@ int main(int argc, char **argv) { free(line); free(desired_indicies); + free(labeled_mers); fclose(fh); return EXIT_SUCCESS; |