-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.c
executable file
·51 lines (45 loc) · 1002 Bytes
/
structs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* AstyanaxPopSim
* \file structs.c
* \author Julien Fumey <[email protected]>, LEGS - CNRS UPR 9034
* \brief Functions for manipulating data structures
* \copyright (C) 2014
* \version 2.0
*/
#include "structs.h"
/**
* \fn void freeLocus(Locus* pop)
* \brief Delete all locus from pop
* \Param pop the linked list to be delete
*/
void freeLocus(Locus* pop){
Locus* temp;
while(pop != NULL){
temp = pop;
pop = pop->next;
free(temp);
temp = NULL;
}
}
/**
* \fn Locus* copyList(Locus* pop)
* \brief Make a copy of the linked list pop
* \Param pop the linked list to be copy
*/
Locus* copyList(Locus* pop){
Locus* locus = calloc(1, sizeof(Locus));
if(locus == NULL){
fprintf(stderr, "error on %s at line %d", __FILE__, __LINE__);
exit(0);
}
locus->cf = pop->cf;
locus->sf = pop->sf;
locus->texas = pop->texas;
locus->gene = pop->gene;
if(pop->next != NULL){
locus->next = copyList(pop->next);
}else{
locus->next = NULL;
}
return locus;
}