commit | author | age
|
0af0cf
|
1 |
#include<general.h> |
d27c07
|
2 |
#include<stdlib.h> |
0af0cf
|
3 |
|
SP |
4 |
|
|
5 |
ts_coord_list *init_coord_list(){ |
|
6 |
ts_coord_list *coordlist=(ts_coord_list *)calloc(1,sizeof(ts_coord_list)); |
|
7 |
if(coordlist==NULL){ |
|
8 |
fatal("Cannot allocate memory for coordlist",999); |
|
9 |
} |
|
10 |
return coordlist; |
|
11 |
} |
|
12 |
|
d27c07
|
13 |
ts_bool add_coord(ts_coord_list *coordlist, ts_double e1, ts_double e2, ts_double e3, ts_uint coord_type){ |
0af0cf
|
14 |
|
d27c07
|
15 |
coordlist->coord=(ts_coord **)realloc(coordlist->coord,(coordlist->n+1)*sizeof(ts_coord *)); |
0af0cf
|
16 |
|
SP |
17 |
if(coordlist->coord==NULL){ |
|
18 |
fatal("Cannot allocate memory for coord in coordlist",998); |
|
19 |
} |
d27c07
|
20 |
|
SP |
21 |
|
|
22 |
coordlist->coord[coordlist->n]=(ts_coord *)calloc(1, sizeof(ts_coord)); |
0af0cf
|
23 |
|
d27c07
|
24 |
coordlist->coord[coordlist->n]->e1=e1; |
SP |
25 |
coordlist->coord[coordlist->n]->e2=e2; |
|
26 |
coordlist->coord[coordlist->n]->e3=e3; |
|
27 |
coordlist->coord[coordlist->n]->coord_type=coord_type; |
|
28 |
coordlist->n++; |
|
29 |
return TS_SUCCESS; |
0af0cf
|
30 |
} |
SP |
31 |
|
d27c07
|
32 |
ts_bool coord_list_free(ts_coord_list *coordlist){ |
0af0cf
|
33 |
ts_uint i; |
SP |
34 |
if(coordlist==NULL) return TS_SUCCESS; |
d27c07
|
35 |
for(i=0; i<coordlist->n;i++){ |
SP |
36 |
if(coordlist->coord[i]!=NULL) free(coordlist->coord[i]); |
0af0cf
|
37 |
} |
d27c07
|
38 |
free(coordlist->coord); |
0af0cf
|
39 |
free(coordlist); |
SP |
40 |
return TS_SUCCESS; |
|
41 |
|
|
42 |
|
|
43 |
} |