From 673ae4aaf8c6423cb494592f43328157d630d6b3 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Mon, 31 Oct 2011 13:26:24 -0400 Subject: [PATCH] throw an error if insufficient memory during index --- bwt.c | 4 ++++ main.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bwt.c b/bwt.c index 5b139d2..38a3c21 100644 --- a/bwt.c +++ b/bwt.c @@ -56,6 +56,10 @@ void bwt_cal_sa(bwt_t *bwt, int intv) bwt->sa_intv = intv; bwt->n_sa = (bwt->seq_len + intv) / intv; bwt->sa = (bwtint_t*)calloc(bwt->n_sa, sizeof(bwtint_t)); + if (bwa->sa == 0) { + fprintf(stderr, "[%s] Fail to allocate %.3fMB memory. Abort!\n", __func__, bwt->n_sa * sizeof(bwtint_t) / 1024.0/1024.0); + abort(); + } // calculate SA value isa = 0; sa = bwt->seq_len; for (i = 0; i < bwt->seq_len; ++i) { diff --git a/main.c b/main.c index 9456140..7f9601f 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,7 @@ #include "utils.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.6.0-r69-dev" +#define PACKAGE_VERSION "0.6.0-r70-dev" #endif static int usage()