diff --git a/src/encode.c b/src/encode.c index 6faebc2..0611b8f 100644 --- a/src/encode.c +++ b/src/encode.c @@ -63,17 +63,14 @@ byte_t* encode_seq_on_2_bits(const char* seq, int32_t length) length_b = ceil((double) length / (double) 4.0); - seq_b = (byte_t*) malloc(length_b * sizeof(byte_t)); + seq_b = (byte_t*) calloc(length_b, sizeof(byte_t)); if (seq_b == NULL) { - obi_set_errno(OBI_MALLOC_ERROR); // TODO + obi_set_errno(OBI_MALLOC_ERROR); obidebug(1, "\nError allocating memory for an encoded DNA sequence"); return NULL; } - // Initialize all the bits to 0 - memset(seq_b, 0, length_b); - for (i=0; i