Index: /issm/trunk-jpl/src/modules/Chaco/Chaco.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/Chaco/Chaco.cpp	(revision 12049)
+++ /issm/trunk-jpl/src/modules/Chaco/Chaco.cpp	(revision 12050)
@@ -58,14 +58,14 @@
 
 	mwstart = mxGetJc(A_IN);
-	start=(int*)xmalloc(nvtxs*sizeof(int));
+	start=(int*)mxMalloc(nvtxs*sizeof(int));
 	for (i=0; i<nvtxs+1;i++)start[i]=(int)mwstart[i];
 
 	mwadjacency = mxGetIr(A_IN);
-	adjacency = (int*)xmalloc(mxGetNzmax(A_IN)*sizeof(int));
+	adjacency = (int*)mxMalloc(mxGetNzmax(A_IN)*sizeof(int));
 	for (i=0; i<mxGetNzmax(A_IN); i++) adjacency[i]= (int)mwadjacency[i];
 
 	nedges = start[nvtxs];
 	if(!mxIsEmpty(EWGTS_IN)){
-		ewgts = (float *) xcalloc(nedges, sizeof(float));
+		ewgts = (float *) mxCalloc(nedges, sizeof(float));
 		doublepointer=mxGetPr(A_IN);
 		for (i = 0; i < nedges; i++)ewgts[i] = (float)doublepointer[i];
@@ -84,5 +84,5 @@
 	
 	FetchData(&npart,NPARTS_IN); 
-	nparts=(int*)xmalloc(sizeof(int)); nparts[0]=npart; //weird Chacox interface ain't it?
+	nparts=(int*)mxMalloc(sizeof(int)); nparts[0]=npart; //weird Chacox interface ain't it?
 
 	FetchData(&goal,&nterms,GOAL_IN); 
@@ -112,5 +112,5 @@
 	
 	/*Allocate output: */
-	assignment = (short *) xcalloc(nvtxs, sizeof(short));
+	assignment = (short *) mxCalloc(nvtxs, sizeof(short));
 	
     /*Call core: */
@@ -118,5 +118,5 @@
 
     /*Output data: */
-	doubleassignment=(double*)xmalloc(nvtxs*sizeof(double));
+	doubleassignment=(double*)mxMalloc(nvtxs*sizeof(double));
 	for (i=0;i<nvtxs;i++) doubleassignment[i]=(double)assignment[i];
 	WriteData(ASSGN_OUT,doubleassignment,nvtxs);
Index: /issm/trunk-jpl/src/modules/ContourToMesh/ContourToMesh.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/ContourToMesh/ContourToMesh.cpp	(revision 12049)
+++ /issm/trunk-jpl/src/modules/ContourToMesh/ContourToMesh.cpp	(revision 12050)
@@ -65,8 +65,8 @@
 	//Fetch contours
 	numcontours=mxGetNumberOfElements(matlabstructure);
-	contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
+	contours=(Contour**)mxMalloc(numcontours*sizeof(Contour*));
 	for(i=0;i<numcontours;i++){
 		//allocate
-		contouri=(Contour*)xmalloc(sizeof(Contour));
+		contouri=(Contour*)mxMalloc(sizeof(Contour));
 		//retrieve dimension of this contour.
 		contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
Index: /issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.cpp	(revision 12049)
+++ /issm/trunk-jpl/src/modules/ContourToNodes/ContourToNodes.cpp	(revision 12050)
@@ -68,8 +68,8 @@
 
 	numcontours=mxGetNumberOfElements(matlabstructure);
-	contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
+	contours=(Contour**)mxMalloc(numcontours*sizeof(Contour*));
 	for(i=0;i<numcontours;i++){
 		//allocate
-		contouri=(Contour*)xmalloc(sizeof(Contour));
+		contouri=(Contour*)mxMalloc(sizeof(Contour));
 		//retrieve dimension of this contour.
 		contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
Index: /issm/trunk-jpl/src/modules/InternalFront/InternalFront.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/InternalFront/InternalFront.cpp	(revision 12049)
+++ /issm/trunk-jpl/src/modules/InternalFront/InternalFront.cpp	(revision 12050)
@@ -36,5 +36,5 @@
 	/*Allocate and initialize all variables*/
 	numberofsegments=0;
-	front=(int*)xmalloc(3*numberofelements*4*sizeof(int));
+	front=(int*)mxMalloc(3*numberofelements*4*sizeof(int));
 
 	/*Loop over all elements on water*/
@@ -81,5 +81,5 @@
 	/*Now that we know how many segments there is we can allocate the final matrix*/
 	if(numberofsegments){
-		front2=(double*)xmalloc(4*numberofsegments*sizeof(double));
+		front2=(double*)mxMalloc(4*numberofsegments*sizeof(double));
 		for(i=0;i<4*numberofsegments;i++) front2[i]=(double)front[i];
 	}
Index: /issm/trunk-jpl/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 12049)
+++ /issm/trunk-jpl/src/modules/InterpFromMesh2d/InterpFromMesh2d.cpp	(revision 12050)
@@ -100,8 +100,8 @@
 		/*contours: */
 		numcontours=mxGetNumberOfElements(matlabstructure);
-		contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
+		contours=(Contour**)mxMalloc(numcontours*sizeof(Contour*));
 		for(i=0;i<numcontours;i++){
 			//allocate
-			contouri=(Contour*)xmalloc(sizeof(Contour));
+			contouri=(Contour*)mxMalloc(sizeof(Contour));
 			//retrieve dimension of this contour.
 			contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
Index: /issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 12049)
+++ /issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 12050)
@@ -78,8 +78,8 @@
 		/*contours: */
 		numcontours=mxGetNumberOfElements(matlabstructure);
-		contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
+		contours=(Contour**)mxMalloc(numcontours*sizeof(Contour*));
 		for(i=0;i<numcontours;i++){
 			//allocate
-			contouri=(Contour*)xmalloc(sizeof(Contour));
+			contouri=(Contour*)mxMalloc(sizeof(Contour));
 			//retrieve dimension of this contour.
 			contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
Index: /issm/trunk-jpl/src/modules/KMLMeshWrite/KMLMeshWrite.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/KMLMeshWrite/KMLMeshWrite.cpp	(revision 12049)
+++ /issm/trunk-jpl/src/modules/KMLMeshWrite/KMLMeshWrite.cpp	(revision 12050)
@@ -55,10 +55,10 @@
 			if (notesi && mxIsChar(notesi) && mxGetNumberOfElements(notesi)) {
 				if (!notes) {
-					notes=(char *) xmalloc((mxGetNumberOfElements(notesi)+1)*sizeof(char));
+					notes=(char *) mxMalloc((mxGetNumberOfElements(notesi)+1)*sizeof(char));
 					mxGetString(notesi,notes,mxGetNumberOfElements(notesi)+1);
 				}
 				else {
 /*  note that strlen does not include trailing null  */
-					notes=(char *) xrealloc(notes,(strlen(notes)+1+mxGetNumberOfElements(notesi)+1)*sizeof(char));
+					notes=(char *) mxRealloc(notes,(strlen(notes)+1+mxGetNumberOfElements(notesi)+1)*sizeof(char));
 					strcat(notes,"\n");
 					mxGetString(notesi,&notes[strlen(notes)],mxGetNumberOfElements(notesi)+1);
Index: /issm/trunk-jpl/src/modules/MeshPartition/MeshPartition.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/MeshPartition/MeshPartition.cpp	(revision 12049)
+++ /issm/trunk-jpl/src/modules/MeshPartition/MeshPartition.cpp	(revision 12050)
@@ -74,10 +74,10 @@
 
 	/*Post process node_partitioning and element_partitioning to be in double format. Metis needed them in int* format: */
-	element_partitioning=(double*)xmalloc(numberofelements*sizeof(double));
+	element_partitioning=(double*)mxMalloc(numberofelements*sizeof(double));
 	for (i=0;i<numberofelements;i++){
 		element_partitioning[i]=(double)int_element_partitioning[i]+1; //Metis indexing from 0, matlab from 1.
 	}
 	
-	node_partitioning=(double*)xmalloc(numberofvertices*sizeof(double));
+	node_partitioning=(double*)mxMalloc(numberofvertices*sizeof(double));
 	for (i=0;i<numberofvertices;i++){
 		node_partitioning[i]=(double)int_node_partitioning[i]+1; //Metis indexing from 0, matlab from 1.
Index: /issm/trunk-jpl/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 12049)
+++ /issm/trunk-jpl/src/modules/MeshProfileIntersection/MeshProfileIntersection.cpp	(revision 12050)
@@ -55,5 +55,5 @@
 	FetchData(&double_index,&nel,&dummy,INDEX);
 	if(dummy!=3 && dummy!=6)_error_(" element triangulation should be of 3 or 6 column width!");
-	index=(int*)xmalloc(nel*3*sizeof(int));
+	index=(int*)mxMalloc(nel*3*sizeof(int));
 	for(i=0;i<nel;i++){
 		for(j=0;j<3;j++){
@@ -67,8 +67,8 @@
 	//contours
 	numcontours=mxGetNumberOfElements(matlabstructure);
-	contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
+	contours=(Contour**)mxMalloc(numcontours*sizeof(Contour*));
 	for(i=0;i<numcontours;i++){
 		//allocate
-		contouri=(Contour*)xmalloc(sizeof(Contour));
+		contouri=(Contour*)mxMalloc(sizeof(Contour));
 		//retrieve dimension of this contour.
 		contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
Index: /issm/trunk-jpl/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 12049)
+++ /issm/trunk-jpl/src/modules/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 12050)
@@ -74,5 +74,5 @@
 		nel=mxGetM(prhs[0]);
 		tindex_in=mxGetPr(prhs[0]);
-		index_in=(double*)xmalloc(nel*3*sizeof(double));
+		index_in=(double*)mxMalloc(nel*3*sizeof(double));
 		for (i=0;i<nel;i++){
 			for (j=0;j<3;j++){
@@ -90,5 +90,5 @@
 		nods=mxGetM(prhs[1]);
 		x_inm=mxGetPr(prhs[1]);
-		x_in=(double*)xmalloc(nods*sizeof(double));
+		x_in=(double*)mxMalloc(nods*sizeof(double));
 		for (i=0;i<nods;i++){
 			x_in[i]=x_inm[i];
@@ -103,5 +103,5 @@
 	if(mxIsDouble(prhs[2])){
 		y_inm=mxGetPr(prhs[2]);
-		y_in=(double*)xmalloc(nods*sizeof(double));
+		y_in=(double*)mxMalloc(nods*sizeof(double));
 		for (i=0;i<nods;i++){
 			y_in[i]=y_inm[i];
@@ -117,5 +117,5 @@
 		num_seg=mxGetM(prhs[3]);
 		tsegments_in=mxGetPr(prhs[3]);
-		segments_in=(double*)xmalloc(num_seg*3*sizeof(double));
+		segments_in=(double*)mxMalloc(num_seg*3*sizeof(double));
 		for (i=0;i<num_seg;i++){
 			for (j=0;j<3;j++){
@@ -132,5 +132,5 @@
 	if(mxIsDouble(prhs[4])){
 		tsegmentmarkers_in=mxGetPr(prhs[4]);
-		segmentmarkers_in=(double*)xmalloc(num_seg*sizeof(double));
+		segmentmarkers_in=(double*)mxMalloc(num_seg*sizeof(double));
 		for (i=0;i<num_seg;i++){
 			segmentmarkers_in[i]=tsegmentmarkers_in[i];
@@ -270,5 +270,5 @@
 			pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
 			mxSetM(pmxa_array2,1);
-			pair=(double*)xmalloc(2*sizeof(double));
+			pair=(double*)mxMalloc(2*sizeof(double));
 			pair[0]=*(out_riftstips+2*i+0);
 			pair[1]=*(out_riftstips+2*i+1);
@@ -293,5 +293,5 @@
 
 			/*State: */
-			state=(double*)xmalloc(out_riftsnumpenaltypairs[i]*sizeof(double));
+			state=(double*)mxMalloc(out_riftsnumpenaltypairs[i]*sizeof(double));
 			for(j=0;j<out_riftsnumpenaltypairs[i];j++)state[j]=FreeEnum;
 			pmxa_array2= mxCreateDoubleMatrix(0,0,mxREAL);
@@ -306,5 +306,5 @@
 	else{
 		/*output NaN :*/
-		pNaN=(double*)xmalloc(sizeof(double));
+		pNaN=(double*)mxMalloc(sizeof(double));
 		*pNaN=NAN;
 		pmxa_array= mxCreateDoubleMatrix(0,0,mxREAL);
Index: /issm/trunk-jpl/src/modules/TriMeshRefine/TriMeshRefine.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/TriMeshRefine/TriMeshRefine.cpp	(revision 12049)
+++ /issm/trunk-jpl/src/modules/TriMeshRefine/TriMeshRefine.cpp	(revision 12050)
@@ -65,5 +65,5 @@
 		nel=mxGetM(prhs[0]);
 		tindex_in=mxGetPr(prhs[0]);
-		index_in=(double*)xmalloc(nel*3*sizeof(double));
+		index_in=(double*)mxMalloc(nel*3*sizeof(double));
 		for (i=0;i<nel;i++){
 			for (j=0;j<3;j++){
@@ -81,5 +81,5 @@
 		nods=mxGetM(prhs[1]);
 		x_inm=mxGetPr(prhs[1]);
-		x_in=(double*)xmalloc(nods*sizeof(double));
+		x_in=(double*)mxMalloc(nods*sizeof(double));
 		for (i=0;i<nods;i++){
 			x_in[i]=x_inm[i];
@@ -94,5 +94,5 @@
 	if(mxIsDouble(prhs[2])){
 		y_inm=mxGetPr(prhs[2]);
-		y_in=(double*)xmalloc(nods*sizeof(double));
+		y_in=(double*)mxMalloc(nods*sizeof(double));
 		for (i=0;i<nods;i++){
 			y_in[i]=y_inm[i];
@@ -108,5 +108,5 @@
 		num_seg=mxGetM(prhs[3]);
 		tsegments_in=mxGetPr(prhs[3]);
-		segments_in=(double*)xmalloc(num_seg*3*sizeof(double));
+		segments_in=(double*)mxMalloc(num_seg*3*sizeof(double));
 		for (i=0;i<num_seg;i++){
 			for (j=0;j<3;j++){
@@ -123,5 +123,5 @@
 	if(mxIsDouble(prhs[4])){
 		tsegmentmarkers_in=mxGetPr(prhs[4]);
-		segmentmarkers_in=(double*)xmalloc(num_seg*sizeof(double));
+		segmentmarkers_in=(double*)mxMalloc(num_seg*sizeof(double));
 		for (i=0;i<num_seg;i++){
 			segmentmarkers_in[i]=tsegmentmarkers_in[i];
@@ -152,5 +152,5 @@
 			mexErrMsgTxt(" ");
 		}
-		order = (char *) xmalloc((mxGetN(prhs[6])+1)*sizeof(char));
+		order = (char *) mxMalloc((mxGetN(prhs[6])+1)*sizeof(char));
 		mxGetString(prhs[6],order,mxGetN(prhs[6])+1);
 	}
@@ -186,5 +186,5 @@
 	in.numberofcorners=3;
 	
-	in.trianglelist = (int *) xmalloc(3*in.numberoftriangles * sizeof(int));
+	in.trianglelist = (int *) mxMalloc(3*in.numberoftriangles * sizeof(int));
 	for(i=0;i<in.numberoftriangles;i++){
 		for(j=0;j<3;j++){
@@ -192,9 +192,9 @@
 		}
 	}
-	in.triangleattributelist = (REAL *) xmalloc(in.numberoftriangles * in.numberoftriangleattributes * sizeof(REAL));
+	in.triangleattributelist = (REAL *) mxMalloc(in.numberoftriangles * in.numberoftriangleattributes * sizeof(REAL));
 	for(i=0;i<in.numberoftriangles;i++){
 		in.triangleattributelist[i]=0.0;
 	}
-	in.trianglearealist = (REAL *) xmalloc(in.numberoftriangles * sizeof(REAL));
+	in.trianglearealist = (REAL *) mxMalloc(in.numberoftriangles * sizeof(REAL));
 	for(i=0;i<in.numberoftriangles;i++){
 		in.trianglearealist[i]=area[i];
@@ -203,10 +203,10 @@
 	in.numberofpoints=nods;
 	in.numberofpointattributes=1;
-	in.pointlist = (REAL *) xmalloc(in.numberofpoints * 2 * sizeof(REAL));
+	in.pointlist = (REAL *) mxMalloc(in.numberofpoints * 2 * sizeof(REAL));
 	for (i=0;i<nods;i++){
 		in.pointlist[2*i+0]=x_in[i];
 		in.pointlist[2*i+1]=y_in[i];
 	}
-	in.pointattributelist = (REAL *) xmalloc(in.numberofpoints * in.numberofpointattributes * sizeof(REAL));
+	in.pointattributelist = (REAL *) mxMalloc(in.numberofpoints * in.numberofpointattributes * sizeof(REAL));
 	for (i=0;i<nods;i++){
 		in.pointattributelist[i] = 0.0;
@@ -214,5 +214,5 @@
 
 	in.numberofsegments = num_seg;
-	in.segmentlist = (int *) xmalloc(in.numberofsegments * 2 * sizeof(REAL));
+	in.segmentlist = (int *) mxMalloc(in.numberofsegments * 2 * sizeof(REAL));
 	in.segmentmarkerlist = (int *) mxCalloc(in.numberofsegments,sizeof(int));
 	for (i=0;i<num_seg;i++){
@@ -250,9 +250,9 @@
 	
 	/*Allocate index, x and y: */
-	index=(double*)xmalloc(3*out.numberoftriangles*sizeof(double));
-	x=(double*)xmalloc(out.numberofpoints*sizeof(double));
-	y=(double*)xmalloc(out.numberofpoints*sizeof(double));
-	segments=(double*)xmalloc(3*out.numberofsegments*sizeof(double));
-	segmentmarkerlist=(double*)xmalloc(out.numberofsegments*sizeof(double));
+	index=(double*)mxMalloc(3*out.numberoftriangles*sizeof(double));
+	x=(double*)mxMalloc(out.numberofpoints*sizeof(double));
+	y=(double*)mxMalloc(out.numberofpoints*sizeof(double));
+	segments=(double*)mxMalloc(3*out.numberofsegments*sizeof(double));
+	segmentmarkerlist=(double*)mxMalloc(out.numberofsegments*sizeof(double));
 
 	for (i = 0; i < out.numberoftriangles; i++) {
