Skip to content

Commit

Permalink
Fix NULL initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
nickjcroucher committed Apr 19, 2024
1 parent 02e5201 commit 9d458a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Newickform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/branch_sequences.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9d458a5

Please sign in to comment.