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