diff options
-rw-r--r-- | kmer_total_count.c | 2 | ||||
-rw-r--r-- | kmer_utils.c | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/kmer_total_count.c b/kmer_total_count.c index 57d4fcc..f15b69c 100644 --- a/kmer_total_count.c +++ b/kmer_total_count.c @@ -116,5 +116,7 @@ int main(int argc, char **argv) { } } } + + free(counts); return EXIT_SUCCESS; } diff --git a/kmer_utils.c b/kmer_utils.c index b29cd24..6736279 100644 --- a/kmer_utils.c +++ b/kmer_utils.c @@ -52,7 +52,7 @@ inline unsigned long num_to_index(const char *str, const int kmer, const long er char *index_to_kmer(unsigned long long index, long kmer) { int num_array[64]; - char *ret = malloc(64); + char *ret = calloc(64, sizeof(char)); if(ret == NULL) exit(EXIT_FAILURE); @@ -117,7 +117,7 @@ unsigned long long * get_kmer_counts_from_file(const char *fn, const unsigned in const unsigned long width = pow_four(kmer); // malloc our return array - unsigned long long * counts = malloc((width+ 1) * sizeof(unsigned long long)); + unsigned long long * counts = calloc((width+ 1), sizeof(unsigned long long)); if(counts == NULL) { fprintf(stderr, strerror(errno)); exit(EXIT_FAILURE); @@ -186,5 +186,8 @@ unsigned long long * get_kmer_counts_from_file(const char *fn, const unsigned in } free(line); + free(str); + fclose(fh); + return counts; } |