From fdb338e3a76f0d83e3ce730b695ceb50295a41b3 Mon Sep 17 00:00:00 2001 From: Nick Croucher Date: Sat, 20 Apr 2024 06:33:31 +0100 Subject: [PATCH] Fix memory allocation statements --- src/Newickform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Newickform.c b/src/Newickform.c index abd18e5e..0214f788 100644 --- a/src/Newickform.c +++ b/src/Newickform.c @@ -245,8 +245,9 @@ newick_node* build_newick_tree(char * filename, FILE *vcf_file_pointer,int * snp // Allocate memory to store all sequences // N.B. this can be reduced once memory management improves int num_stored_nodes = num_nodes; - char ** node_sequences = (char **) calloc((number_of_snps + 1)*num_stored_nodes,sizeof(char)); - char ** node_names = (char **) calloc(MAX_SAMPLE_NAME_SIZE*num_stored_nodes,sizeof(char)); + char ** node_sequences = calloc((number_of_snps + 1) * num_stored_nodes, sizeof(char*)); + char ** node_names = calloc(MAX_SAMPLE_NAME_SIZE*num_stored_nodes,sizeof(char)); + for (int seq_store_index = 0; seq_store_index < num_stored_nodes; ++seq_store_index) { node_names[seq_store_index] = " ";