From 9d458a5354252f41809f6bc70c8b7750e2146ce4 Mon Sep 17 00:00:00 2001 From: Nick Croucher Date: Fri, 19 Apr 2024 19:05:29 +0100 Subject: [PATCH] Fix NULL initialisation --- src/Newickform.c | 6 +++--- src/branch_sequences.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Newickform.c b/src/Newickform.c index 764ddca1..f651cbb8 100644 --- a/src/Newickform.c +++ b/src/Newickform.c @@ -245,11 +245,11 @@ 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 = (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)); for (int seq_store_index = 0; seq_store_index < num_stored_nodes; ++seq_store_index) { - node_names[seq_store_index] = ' '; + node_names[seq_store_index] = NULL; } // iterate through depths and identify batches of analyses to be run diff --git a/src/branch_sequences.c b/src/branch_sequences.c index 3598f3b6..86a62a4a 100644 --- a/src/branch_sequences.c +++ b/src/branch_sequences.c @@ -410,7 +410,7 @@ void generate_branch_sequences(newick_node *node, char ** node_sequences, char * // Store node sequence for (int seq_store_index = 0; seq_store_index < num_stored_nodes; ++seq_store_index) { - if (node_names[seq_store_index] == ' ') { + if (node_names[seq_store_index] == NULL) { node_names[seq_store_index] = node->taxon; node_sequences[seq_store_index] = node_sequence; break;