| | |
| | | #include<general.h> |
| | | |
| | | #include<stdlib.h> |
| | | |
| | | |
| | | ts_coord_list *init_coord_list(){ |
| | |
| | | return coordlist; |
| | | } |
| | | |
| | | ts_coord_list add_coord(ts_coord_list *coordlist, ts_double e1, ts_double e2, ts_double e3, ts_uint coord_type){ |
| | | ts_bool add_coord(ts_coord_list *coordlist, ts_double e1, ts_double e2, ts_double e3, ts_uint coord_type){ |
| | | |
| | | coordlist->N++; |
| | | coordlist->coord=(ts_coord *)realloc(coordlist->coord,N*sizeof(ts_coord)); |
| | | coordlist->coord=(ts_coord **)realloc(coordlist->coord,(coordlist->n+1)*sizeof(ts_coord *)); |
| | | |
| | | if(coordlist->coord==NULL){ |
| | | fatal("Cannot allocate memory for coord in coordlist",998); |
| | | } |
| | | |
| | | |
| | | coordlist->coord[coordlist->n]=(ts_coord *)calloc(1, sizeof(ts_coord)); |
| | | |
| | | coordlist->coord[coordlist->N-1]->e1=e1; |
| | | coordlist->coord[coordlist->N-1]->e2=e2; |
| | | coordlist->coord[coordlist->N-1]->e3=e3; |
| | | coordlist->coord[coordlist->N-1]->coord_type=coord_type; |
| | | |
| | | coordlist->coord[coordlist->n]->e1=e1; |
| | | coordlist->coord[coordlist->n]->e2=e2; |
| | | coordlist->coord[coordlist->n]->e3=e3; |
| | | coordlist->coord[coordlist->n]->coord_type=coord_type; |
| | | coordlist->n++; |
| | | return TS_SUCCESS; |
| | | } |
| | | |
| | | ts_bool coord_list_free(ts_coord_list coordlist){ |
| | | ts_bool coord_list_free(ts_coord_list *coordlist){ |
| | | ts_uint i; |
| | | if(coordlist==NULL) return TS_SUCCESS; |
| | | for(i=0; i<coordlist->N;i++){ |
| | | if(coordlist->coord[N]!=NULL) free(coordlist->coord[N]); |
| | | for(i=0; i<coordlist->n;i++){ |
| | | if(coordlist->coord[i]!=NULL) free(coordlist->coord[i]); |
| | | } |
| | | |
| | | free(coordlist->coord); |
| | | free(coordlist); |
| | | return TS_SUCCESS; |
| | | |