newGene->exon_stops = malloc(2*sizeof(int));
newGene->num_exons = 0;
newGene->max_exons = 2;
- newGene->start = -1;
-
return newGene;
}
}
void add_exon(struct gene* currentGene,int start, int stop) {
+ int idx = currentGene->num_exons;
- if (currentGene->num_exons < currentGene->num_exons) {
- int idx = currentGene->num_exons;
- currentGene->exon_starts[idx] = start;
- currentGene->exon_stops[idx] = stop;
- currentGene->num_exons++;
- } else {
+ if ( idx >= currentGene->max_exons) {
currentGene->exon_starts = realloc(currentGene->exon_starts,sizeof(int)*2*currentGene->max_exons);
currentGene->exon_stops = realloc(currentGene->exon_stops,sizeof(int)*2*currentGene->max_exons);
+ currentGene->max_exons *= 2;
}
+
+ currentGene->exon_starts[idx] = start;
+ currentGene->exon_stops[idx] = stop;
+ currentGene->num_exons++;
}