4 #include "datastructures.h"
6 struct gene
* gene_alloc(void) {
7 struct gene
* newGene
= (struct gene
*) malloc(sizeof(struct gene
));
8 newGene
->exon_starts
= malloc(2*sizeof(int));
9 newGene
->exon_stops
= malloc(2*sizeof(int));
10 newGene
->num_exons
= 0;
11 newGene
->max_exons
= 2;
17 void free_gene(struct gene
* oldGene
) {
18 free(oldGene
->exon_starts
);
19 free(oldGene
->exon_stops
);
22 void add_exon(struct gene
* currentGene
,int start
, int stop
) {
24 if (currentGene
->num_exons
< currentGene
->num_exons
) {
25 int idx
= currentGene
->num_exons
;
26 currentGene
->exon_starts
[idx
] = start
;
27 currentGene
->exon_stops
[idx
] = stop
;
28 currentGene
->num_exons
++;
30 currentGene
->exon_starts
= realloc(currentGene
->exon_starts
,sizeof(int)*2*currentGene
->max_exons
);
31 currentGene
->exon_stops
= realloc(currentGene
->exon_stops
,sizeof(int)*2*currentGene
->max_exons
);