Changeset 12050
- Timestamp:
- 04/18/12 15:17:58 (13 years ago)
- Location:
- issm/trunk-jpl/src/modules
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/modules/Chaco/Chaco.cpp
r11933 r12050 58 58 59 59 mwstart = mxGetJc(A_IN); 60 start=(int*) xmalloc(nvtxs*sizeof(int));60 start=(int*)mxMalloc(nvtxs*sizeof(int)); 61 61 for (i=0; i<nvtxs+1;i++)start[i]=(int)mwstart[i]; 62 62 63 63 mwadjacency = mxGetIr(A_IN); 64 adjacency = (int*) xmalloc(mxGetNzmax(A_IN)*sizeof(int));64 adjacency = (int*)mxMalloc(mxGetNzmax(A_IN)*sizeof(int)); 65 65 for (i=0; i<mxGetNzmax(A_IN); i++) adjacency[i]= (int)mwadjacency[i]; 66 66 67 67 nedges = start[nvtxs]; 68 68 if(!mxIsEmpty(EWGTS_IN)){ 69 ewgts = (float *) xcalloc(nedges, sizeof(float));69 ewgts = (float *) mxCalloc(nedges, sizeof(float)); 70 70 doublepointer=mxGetPr(A_IN); 71 71 for (i = 0; i < nedges; i++)ewgts[i] = (float)doublepointer[i]; … … 84 84 85 85 FetchData(&npart,NPARTS_IN); 86 nparts=(int*) xmalloc(sizeof(int)); nparts[0]=npart; //weird Chacox interface ain't it?86 nparts=(int*)mxMalloc(sizeof(int)); nparts[0]=npart; //weird Chacox interface ain't it? 87 87 88 88 FetchData(&goal,&nterms,GOAL_IN); … … 112 112 113 113 /*Allocate output: */ 114 assignment = (short *) xcalloc(nvtxs, sizeof(short));114 assignment = (short *) mxCalloc(nvtxs, sizeof(short)); 115 115 116 116 /*Call core: */ … … 118 118 119 119 /*Output data: */ 120 doubleassignment=(double*) xmalloc(nvtxs*sizeof(double));120 doubleassignment=(double*)mxMalloc(nvtxs*sizeof(double)); 121 121 for (i=0;i<nvtxs;i++) doubleassignment[i]=(double)assignment[i]; 122 122 WriteData(ASSGN_OUT,doubleassignment,nvtxs); -
issm/trunk-jpl/src/modules/ContourToMesh/ContourToMesh.cpp
r11933 r12050 65 65 //Fetch contours 66 66 numcontours=mxGetNumberOfElements(matlabstructure); 67 contours=(Contour**) xmalloc(numcontours*sizeof(Contour*));67 contours=(Contour**)mxMalloc(numcontours*sizeof(Contour*)); 68 68 for(i=0;i<numcontours;i++){ 69 69 //allocate 70 contouri=(Contour*) xmalloc(sizeof(Contour));70 contouri=(Contour*)mxMalloc(sizeof(Contour)); 71 71 //retrieve dimension of this contour. 72 72 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.cpp
r11933 r12050 68 68 69 69 numcontours=mxGetNumberOfElements(matlabstructure); 70 contours=(Contour**) xmalloc(numcontours*sizeof(Contour*));70 contours=(Contour**)mxMalloc(numcontours*sizeof(Contour*)); 71 71 for(i=0;i<numcontours;i++){ 72 72 //allocate 73 contouri=(Contour*) xmalloc(sizeof(Contour));73 contouri=(Contour*)mxMalloc(sizeof(Contour)); 74 74 //retrieve dimension of this contour. 75 75 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
issm/trunk-jpl/src/modules/InternalFront/InternalFront.cpp
r11933 r12050 36 36 /*Allocate and initialize all variables*/ 37 37 numberofsegments=0; 38 front=(int*) xmalloc(3*numberofelements*4*sizeof(int));38 front=(int*)mxMalloc(3*numberofelements*4*sizeof(int)); 39 39 40 40 /*Loop over all elements on water*/ … … 81 81 /*Now that we know how many segments there is we can allocate the final matrix*/ 82 82 if(numberofsegments){ 83 front2=(double*) xmalloc(4*numberofsegments*sizeof(double));83 front2=(double*)mxMalloc(4*numberofsegments*sizeof(double)); 84 84 for(i=0;i<4*numberofsegments;i++) front2[i]=(double)front[i]; 85 85 } -
issm/trunk-jpl/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp
r11933 r12050 100 100 /*contours: */ 101 101 numcontours=mxGetNumberOfElements(matlabstructure); 102 contours=(Contour**) xmalloc(numcontours*sizeof(Contour*));102 contours=(Contour**)mxMalloc(numcontours*sizeof(Contour*)); 103 103 for(i=0;i<numcontours;i++){ 104 104 //allocate 105 contouri=(Contour*) xmalloc(sizeof(Contour));105 contouri=(Contour*)mxMalloc(sizeof(Contour)); 106 106 //retrieve dimension of this contour. 107 107 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
r11933 r12050 78 78 /*contours: */ 79 79 numcontours=mxGetNumberOfElements(matlabstructure); 80 contours=(Contour**) xmalloc(numcontours*sizeof(Contour*));80 contours=(Contour**)mxMalloc(numcontours*sizeof(Contour*)); 81 81 for(i=0;i<numcontours;i++){ 82 82 //allocate 83 contouri=(Contour*) xmalloc(sizeof(Contour));83 contouri=(Contour*)mxMalloc(sizeof(Contour)); 84 84 //retrieve dimension of this contour. 85 85 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
issm/trunk-jpl/src/modules/KMLMeshWrite/KMLMeshWrite.cpp
r12049 r12050 55 55 if (notesi && mxIsChar(notesi) && mxGetNumberOfElements(notesi)) { 56 56 if (!notes) { 57 notes=(char *) xmalloc((mxGetNumberOfElements(notesi)+1)*sizeof(char));57 notes=(char *) mxMalloc((mxGetNumberOfElements(notesi)+1)*sizeof(char)); 58 58 mxGetString(notesi,notes,mxGetNumberOfElements(notesi)+1); 59 59 } 60 60 else { 61 61 /* note that strlen does not include trailing null */ 62 notes=(char *) xrealloc(notes,(strlen(notes)+1+mxGetNumberOfElements(notesi)+1)*sizeof(char));62 notes=(char *) mxRealloc(notes,(strlen(notes)+1+mxGetNumberOfElements(notesi)+1)*sizeof(char)); 63 63 strcat(notes,"\n"); 64 64 mxGetString(notesi,¬es[strlen(notes)],mxGetNumberOfElements(notesi)+1); -
issm/trunk-jpl/src/modules/MeshPartition/MeshPartition.cpp
r11933 r12050 74 74 75 75 /*Post process node_partitioning and element_partitioning to be in double format. Metis needed them in int* format: */ 76 element_partitioning=(double*) xmalloc(numberofelements*sizeof(double));76 element_partitioning=(double*)mxMalloc(numberofelements*sizeof(double)); 77 77 for (i=0;i<numberofelements;i++){ 78 78 element_partitioning[i]=(double)int_element_partitioning[i]+1; //Metis indexing from 0, matlab from 1. 79 79 } 80 80 81 node_partitioning=(double*) xmalloc(numberofvertices*sizeof(double));81 node_partitioning=(double*)mxMalloc(numberofvertices*sizeof(double)); 82 82 for (i=0;i<numberofvertices;i++){ 83 83 node_partitioning[i]=(double)int_node_partitioning[i]+1; //Metis indexing from 0, matlab from 1. -
issm/trunk-jpl/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp
r11933 r12050 55 55 FetchData(&double_index,&nel,&dummy,INDEX); 56 56 if(dummy!=3 && dummy!=6)_error_(" element triangulation should be of 3 or 6 column width!"); 57 index=(int*) xmalloc(nel*3*sizeof(int));57 index=(int*)mxMalloc(nel*3*sizeof(int)); 58 58 for(i=0;i<nel;i++){ 59 59 for(j=0;j<3;j++){ … … 67 67 //contours 68 68 numcontours=mxGetNumberOfElements(matlabstructure); 69 contours=(Contour**) xmalloc(numcontours*sizeof(Contour*));69 contours=(Contour**)mxMalloc(numcontours*sizeof(Contour*)); 70 70 for(i=0;i<numcontours;i++){ 71 71 //allocate 72 contouri=(Contour*) xmalloc(sizeof(Contour));72 contouri=(Contour*)mxMalloc(sizeof(Contour)); 73 73 //retrieve dimension of this contour. 74 74 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); -
issm/trunk-jpl/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp
r8963 r12050 74 74 nel=mxGetM(prhs[0]); 75 75 tindex_in=mxGetPr(prhs[0]); 76 index_in=(double*) xmalloc(nel*3*sizeof(double));76 index_in=(double*)mxMalloc(nel*3*sizeof(double)); 77 77 for (i=0;i<nel;i++){ 78 78 for (j=0;j<3;j++){ … … 90 90 nods=mxGetM(prhs[1]); 91 91 x_inm=mxGetPr(prhs[1]); 92 x_in=(double*) xmalloc(nods*sizeof(double));92 x_in=(double*)mxMalloc(nods*sizeof(double)); 93 93 for (i=0;i<nods;i++){ 94 94 x_in[i]=x_inm[i]; … … 103 103 if(mxIsDouble(prhs[2])){ 104 104 y_inm=mxGetPr(prhs[2]); 105 y_in=(double*) xmalloc(nods*sizeof(double));105 y_in=(double*)mxMalloc(nods*sizeof(double)); 106 106 for (i=0;i<nods;i++){ 107 107 y_in[i]=y_inm[i]; … … 117 117 num_seg=mxGetM(prhs[3]); 118 118 tsegments_in=mxGetPr(prhs[3]); 119 segments_in=(double*) xmalloc(num_seg*3*sizeof(double));119 segments_in=(double*)mxMalloc(num_seg*3*sizeof(double)); 120 120 for (i=0;i<num_seg;i++){ 121 121 for (j=0;j<3;j++){ … … 132 132 if(mxIsDouble(prhs[4])){ 133 133 tsegmentmarkers_in=mxGetPr(prhs[4]); 134 segmentmarkers_in=(double*) xmalloc(num_seg*sizeof(double));134 segmentmarkers_in=(double*)mxMalloc(num_seg*sizeof(double)); 135 135 for (i=0;i<num_seg;i++){ 136 136 segmentmarkers_in[i]=tsegmentmarkers_in[i]; … … 270 270 pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL); 271 271 mxSetM(pmxa_array2,1); 272 pair=(double*) xmalloc(2*sizeof(double));272 pair=(double*)mxMalloc(2*sizeof(double)); 273 273 pair[0]=*(out_riftstips+2*i+0); 274 274 pair[1]=*(out_riftstips+2*i+1); … … 293 293 294 294 /*State: */ 295 state=(double*) xmalloc(out_riftsnumpenaltypairs[i]*sizeof(double));295 state=(double*)mxMalloc(out_riftsnumpenaltypairs[i]*sizeof(double)); 296 296 for(j=0;j<out_riftsnumpenaltypairs[i];j++)state[j]=FreeEnum; 297 297 pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL); … … 306 306 else{ 307 307 /*output NaN :*/ 308 pNaN=(double*) xmalloc(sizeof(double));308 pNaN=(double*)mxMalloc(sizeof(double)); 309 309 *pNaN=NAN; 310 310 pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL); -
issm/trunk-jpl/src/modules/TriMeshRefine/TriMeshRefine.cpp
r4526 r12050 65 65 nel=mxGetM(prhs[0]); 66 66 tindex_in=mxGetPr(prhs[0]); 67 index_in=(double*) xmalloc(nel*3*sizeof(double));67 index_in=(double*)mxMalloc(nel*3*sizeof(double)); 68 68 for (i=0;i<nel;i++){ 69 69 for (j=0;j<3;j++){ … … 81 81 nods=mxGetM(prhs[1]); 82 82 x_inm=mxGetPr(prhs[1]); 83 x_in=(double*) xmalloc(nods*sizeof(double));83 x_in=(double*)mxMalloc(nods*sizeof(double)); 84 84 for (i=0;i<nods;i++){ 85 85 x_in[i]=x_inm[i]; … … 94 94 if(mxIsDouble(prhs[2])){ 95 95 y_inm=mxGetPr(prhs[2]); 96 y_in=(double*) xmalloc(nods*sizeof(double));96 y_in=(double*)mxMalloc(nods*sizeof(double)); 97 97 for (i=0;i<nods;i++){ 98 98 y_in[i]=y_inm[i]; … … 108 108 num_seg=mxGetM(prhs[3]); 109 109 tsegments_in=mxGetPr(prhs[3]); 110 segments_in=(double*) xmalloc(num_seg*3*sizeof(double));110 segments_in=(double*)mxMalloc(num_seg*3*sizeof(double)); 111 111 for (i=0;i<num_seg;i++){ 112 112 for (j=0;j<3;j++){ … … 123 123 if(mxIsDouble(prhs[4])){ 124 124 tsegmentmarkers_in=mxGetPr(prhs[4]); 125 segmentmarkers_in=(double*) xmalloc(num_seg*sizeof(double));125 segmentmarkers_in=(double*)mxMalloc(num_seg*sizeof(double)); 126 126 for (i=0;i<num_seg;i++){ 127 127 segmentmarkers_in[i]=tsegmentmarkers_in[i]; … … 152 152 mexErrMsgTxt(" "); 153 153 } 154 order = (char *) xmalloc((mxGetN(prhs[6])+1)*sizeof(char));154 order = (char *) mxMalloc((mxGetN(prhs[6])+1)*sizeof(char)); 155 155 mxGetString(prhs[6],order,mxGetN(prhs[6])+1); 156 156 } … … 186 186 in.numberofcorners=3; 187 187 188 in.trianglelist = (int *) xmalloc(3*in.numberoftriangles * sizeof(int));188 in.trianglelist = (int *) mxMalloc(3*in.numberoftriangles * sizeof(int)); 189 189 for(i=0;i<in.numberoftriangles;i++){ 190 190 for(j=0;j<3;j++){ … … 192 192 } 193 193 } 194 in.triangleattributelist = (REAL *) xmalloc(in.numberoftriangles * in.numberoftriangleattributes * sizeof(REAL));194 in.triangleattributelist = (REAL *) mxMalloc(in.numberoftriangles * in.numberoftriangleattributes * sizeof(REAL)); 195 195 for(i=0;i<in.numberoftriangles;i++){ 196 196 in.triangleattributelist[i]=0.0; 197 197 } 198 in.trianglearealist = (REAL *) xmalloc(in.numberoftriangles * sizeof(REAL));198 in.trianglearealist = (REAL *) mxMalloc(in.numberoftriangles * sizeof(REAL)); 199 199 for(i=0;i<in.numberoftriangles;i++){ 200 200 in.trianglearealist[i]=area[i]; … … 203 203 in.numberofpoints=nods; 204 204 in.numberofpointattributes=1; 205 in.pointlist = (REAL *) xmalloc(in.numberofpoints * 2 * sizeof(REAL));205 in.pointlist = (REAL *) mxMalloc(in.numberofpoints * 2 * sizeof(REAL)); 206 206 for (i=0;i<nods;i++){ 207 207 in.pointlist[2*i+0]=x_in[i]; 208 208 in.pointlist[2*i+1]=y_in[i]; 209 209 } 210 in.pointattributelist = (REAL *) xmalloc(in.numberofpoints * in.numberofpointattributes * sizeof(REAL));210 in.pointattributelist = (REAL *) mxMalloc(in.numberofpoints * in.numberofpointattributes * sizeof(REAL)); 211 211 for (i=0;i<nods;i++){ 212 212 in.pointattributelist[i] = 0.0; … … 214 214 215 215 in.numberofsegments = num_seg; 216 in.segmentlist = (int *) xmalloc(in.numberofsegments * 2 * sizeof(REAL));216 in.segmentlist = (int *) mxMalloc(in.numberofsegments * 2 * sizeof(REAL)); 217 217 in.segmentmarkerlist = (int *) mxCalloc(in.numberofsegments,sizeof(int)); 218 218 for (i=0;i<num_seg;i++){ … … 250 250 251 251 /*Allocate index, x and y: */ 252 index=(double*) xmalloc(3*out.numberoftriangles*sizeof(double));253 x=(double*) xmalloc(out.numberofpoints*sizeof(double));254 y=(double*) xmalloc(out.numberofpoints*sizeof(double));255 segments=(double*) xmalloc(3*out.numberofsegments*sizeof(double));256 segmentmarkerlist=(double*) xmalloc(out.numberofsegments*sizeof(double));252 index=(double*)mxMalloc(3*out.numberoftriangles*sizeof(double)); 253 x=(double*)mxMalloc(out.numberofpoints*sizeof(double)); 254 y=(double*)mxMalloc(out.numberofpoints*sizeof(double)); 255 segments=(double*)mxMalloc(3*out.numberofsegments*sizeof(double)); 256 segmentmarkerlist=(double*)mxMalloc(out.numberofsegments*sizeof(double)); 257 257 258 258 for (i = 0; i < out.numberoftriangles; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.