From dd39482f495a660d125ed9b4a352993a47e9d7d9 Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Mon, 24 Feb 2014 12:17:15 -0500 Subject: add more verbose error messages and add more memory checks --- kmer_counts_per_sequence.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'kmer_counts_per_sequence.c') diff --git a/kmer_counts_per_sequence.c b/kmer_counts_per_sequence.c index 2b95ed1..bd18f04 100644 --- a/kmer_counts_per_sequence.c +++ b/kmer_counts_per_sequence.c @@ -131,8 +131,10 @@ int main(int argc, char **argv) { if(specific_mers) { sparse = false; desired_indicies = malloc((width) * sizeof(size_t)); - if(desired_indicies == NULL) + if(desired_indicies == NULL) { + fprintf(stderr, "%s\n", strerror(errno)); exit(EXIT_FAILURE); + } num_desired_indicies = load_specific_mers_from_file(mer_fn, kmer, width, desired_indicies); if(num_desired_indicies == 0) { fprintf(stderr, "Error: no mers loaded from file"); @@ -142,8 +144,10 @@ int main(int argc, char **argv) { unsigned long long *counts = malloc((width+ 1) * sizeof(unsigned long long)); - if(counts == NULL) + if(counts == NULL) { + fprintf(stderr, "%s\n", strerror(errno)); exit(EXIT_FAILURE); + } unsigned long long sequence = 0; while ((read = getdelim(&line, &len, '>', fh)) != -1) { @@ -197,11 +201,11 @@ int main(int argc, char **argv) { sequence++; } -free(counts); -free(line); -free(desired_indicies); -fclose(fh); + free(counts); + free(line); + free(desired_indicies); + fclose(fh); -return EXIT_SUCCESS; + return EXIT_SUCCESS; } -- cgit v1.2.3