aboutsummaryrefslogtreecommitdiff
path: root/kmer_counts_per_sequence.c
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2014-02-24 12:17:15 -0500
committerCalvin Morrison <mutantturkey@gmail.com>2014-02-24 12:17:15 -0500
commitdd39482f495a660d125ed9b4a352993a47e9d7d9 (patch)
treeb51d1754bf6990a8b53e2a79c027afda60672d68 /kmer_counts_per_sequence.c
parent1c2ce90501d87db6431a7f29a37876d61347aff7 (diff)
add more verbose error messages and add more memory checks
Diffstat (limited to 'kmer_counts_per_sequence.c')
-rw-r--r--kmer_counts_per_sequence.c18
1 files changed, 11 insertions, 7 deletions
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;
}