Hi all,
I've got a segmentation fault occurring that I don't understand, and I'd appreciate your help. First, the relevant structure
Here is the function definitionCode:typedef struct node { //sequence for this node amino_acid_list *sequence; // not currently used- in case sequence length changes int sequence_length; // distance (in amino acid substitutions) int mutation_distance_from_parent; int mutation_distance_to_left; int mutation_distance_to_right; // distance (absolute? not yet used) int distance_from_parent; int distance_to_left; int distance_to_right; // depth of this node int depth; // debugging long int data; // pointers struct node *parent_ptr; struct node *left_ptr; struct node *right_ptr; } node
And here is the offending piece of code within the function build_tree_with_constraintsCode:node *build_tree_with_constraints(node *n, node* nprev, int depth, int maxdepth, amino_acid_list *parent_sequence, int sequence_length, float ........r, float **tpm, int dist, float random_param_one, float random_param_two, int burnin, incompatability_matrix **icm, int num_amino_acids, int type, int *num_mutations);
Here is the outputCode:n->left_ptr= build_tree_with_constraints(n->left_ptr, n, n->depth+1, maxdepth, n->sequence, sequence_length, ssr, tpm, dist, random_param_one, random_param_two, burnin, icm, num_amino_acids, type, num_mutations); // make sure that we get the correct output here printf("LEFT- number of mutations is %d\n", *num_mutations); // set the distance to the left offspring node n->mutation_distance_to_left= *num_mutations; printf("one\n"); n->left_ptr->mutation_distance_from_parent= *num_mutations; printf("two\n");
I don't understand whyCode:number of mutations is 48 LEFT- number of mutations is 48 uno Segmentation fault
works, butCode:n->mutation_distance_to_left= *num_mutations;
Doesn't. I've also triedCode:n->left_ptr->mutation_distance_from_parent= *num_mutations;
But that doesn't help either. So obviously I'm missing something fairly basic, but I don't know what it is.Code:(n->left_ptr)->mutation_distance_from_parent= *num_mutations;
Thanks a lot,
Brad



LinkBack URL
About LinkBacks


