From a50bc3833b9c8eb8a510934b3fc4e3b3eb38dec0 Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Mon, 14 Apr 2014 14:01:58 -0400 Subject: fix malloc in locations --- kmer_locations.c | 8 ++------ 1 file 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; -- cgit v1.2.3