Index: /issm/trunk-jpl/src/c/Container/DataSet.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/DataSet.cpp	(revision 12458)
+++ /issm/trunk-jpl/src/c/Container/DataSet.cpp	(revision 12459)
@@ -59,9 +59,9 @@
 	copy->presorted=presorted;
 	if(sorted_ids){
-		copy->sorted_ids=(int*)xmalloc(objects.size()*sizeof(int));
+		copy->sorted_ids=xNew<int>(objects.size());
 		memcpy(copy->sorted_ids,sorted_ids,objects.size()*sizeof(int));
 	}
 	if(id_offsets){
-		copy->id_offsets=(int*)xmalloc(objects.size()*sizeof(int));
+		copy->id_offsets=xNew<int>(objects.size());
 		memcpy(copy->id_offsets,id_offsets,objects.size()*sizeof(int));
 	}
@@ -80,6 +80,6 @@
 DataSet::~DataSet(){
 	clear();
-	xfree((void**)&sorted_ids);
-	xfree((void**)&id_offsets);
+	xDelete<int>(sorted_ids);
+	xDelete<int>(id_offsets);
 }
 /*}}}*/
@@ -221,10 +221,10 @@
 
 		/*Delete existing ids*/
-		xfree((void**)&sorted_ids);
-		xfree((void**)&id_offsets);
+		xDelete<int>(sorted_ids);
+		xDelete<int>(id_offsets);
 
 		/*Allocate new ids*/
-		sorted_ids=(int*)xmalloc(objects.size()*sizeof(int));
-		id_offsets=(int*)xmalloc(objects.size()*sizeof(int));
+		sorted_ids=xNew<int>(objects.size());
+		id_offsets=xNew<int>(objects.size());
 
 		/*Build id_offsets and sorted_ids*/
Index: /issm/trunk-jpl/src/c/Container/Elements.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Elements.cpp	(revision 12458)
+++ /issm/trunk-jpl/src/c/Container/Elements.cpp	(revision 12459)
@@ -215,8 +215,8 @@
 		#ifdef _HAVE_MPI_
 		if(my_rank!=minrank){
-			resultsenums=(int*)xmalloc(numberofresults*sizeof(int));
-			resultssizes=(int*)xmalloc(numberofresults*sizeof(int));
-			resultstimes=(double*)xmalloc(numberofresults*sizeof(double));
-			resultssteps=(int*)xmalloc(numberofresults*sizeof(int));
+			resultsenums=xNew<int>(numberofresults);
+			resultssizes=xNew<int>(numberofresults);
+			resultstimes=xNew<double>(numberofresults);
+			resultssteps=xNew<int>(numberofresults);
 		}
 		MPI_Bcast(resultsenums,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD);
@@ -250,5 +250,5 @@
 			/*clean up*/
 			xdelete(&vector);
-			xfree((void**)&vector_serial);
+			xDelete<double>(vector_serial);
 		}
 	}
@@ -269,8 +269,8 @@
 
 	/*Free ressources:*/
-	xfree((void**)&resultsenums);
-	xfree((void**)&resultssizes);
-	xfree((void**)&resultstimes);
-	xfree((void**)&resultssteps);
+	xDelete<int>(resultsenums);
+	xDelete<int>(resultssizes);
+	xDelete<int>(resultssteps);
+	xDelete<double>(resultstimes);
 	delete patch;
 }
Index: /issm/trunk-jpl/src/c/Container/Nodes.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Nodes.cpp	(revision 12458)
+++ /issm/trunk-jpl/src/c/Container/Nodes.cpp	(revision 12459)
@@ -84,5 +84,5 @@
 	 * cpus by the total last dofs of the previus cpu, starting from 0.
 	 * First: get number of dofs for each cpu*/
-	alldofcount=(int*)xmalloc(num_procs*sizeof(int));
+	alldofcount=xNew<int>(num_procs);
 	#ifdef _HAVE_MPI_
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
@@ -113,6 +113,6 @@
 	numnodes=this->NumberOfNodes(analysis_type);
 	if(numnodes*maxdofspernode){
-		truedofs=   (int*)xcalloc(numnodes*maxdofspernode,sizeof(int)); //initialize to 0, so that we can pick up the max
-		alltruedofs=(int*)xcalloc(numnodes*maxdofspernode,sizeof(int));
+		truedofs=   xNewZeroInit<int>(numnodes*maxdofspernode); //initialize to 0, so that we can pick up the max
+		alltruedofs=xNewZeroInit<int>(numnodes*maxdofspernode);
 	}
 
@@ -139,7 +139,7 @@
 
 	/* Free ressources: */
-	xfree((void**)&alldofcount);
-	xfree((void**)&truedofs);
-	xfree((void**)&alltruedofs);
+	xDelete<int>(alldofcount);
+	xDelete<int>(truedofs);
+	xDelete<int>(alltruedofs);
 }
 /*}}}*/
@@ -158,6 +158,6 @@
 
 	/*Allocate ranks: */
-	ranks=(int*)xmalloc(numnodes*sizeof(int));
-	minranks=(int*)xmalloc(numnodes*sizeof(int));
+	ranks=xNew<int>(numnodes);
+	minranks=xNew<int>(numnodes);
 
 	for(i=0;i<numnodes;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit.
@@ -190,6 +190,6 @@
 
 	/*Free ressources: */
-	xfree((void**)&ranks); 
-	xfree((void**)&minranks);
+	xDelete<int>(ranks); 
+	xDelete<int>(minranks);
 
 }
Index: /issm/trunk-jpl/src/c/Container/Observations.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Observations.cpp	(revision 12458)
+++ /issm/trunk-jpl/src/c/Container/Observations.cpp	(revision 12459)
@@ -162,5 +162,5 @@
 		*pobs=observation->value;
 	}
-	xfree((void**)&indices);
+	xDelete<int>(indices);
 
 }/*}}}*/
@@ -189,6 +189,6 @@
 	this->quadtree->RangeSearch(&tempindices,&tempnobs,x_interp,y_interp,radius);
 	if(tempnobs){
-		indices = (int*)xmalloc(tempnobs*sizeof(int));
-		dists   = (double*)xmalloc(tempnobs*sizeof(double));
+		indices = xNew<int>(tempnobs);
+		dists   = xNew<double>(tempnobs);
 	}
 	nobs = 0;
@@ -225,12 +225,12 @@
 		}
 	}  
-	xfree((void**)&dists);
-	xfree((void**)&tempindices);
+	xDelete<double>(dists);
+	xDelete<int>(tempindices);
 
 	if(nobs){
 		/*Allocate vectors*/
-		x   = (double*)xmalloc(nobs*sizeof(double));
-		y   = (double*)xmalloc(nobs*sizeof(double));
-		obs = (double*)xmalloc(nobs*sizeof(double));
+		x   = xNew<double>(nobs);
+		y   = xNew<double>(nobs);
+		obs = xNew<double>(nobs);
 
 		/*Loop over all observations and fill in x, y and obs*/
@@ -242,5 +242,5 @@
 
 	/*Assign output pointer*/
-	xfree((void**)&indices);
+	xDelete<int>(indices);
 	*px=x;
 	*py=y;
@@ -261,7 +261,7 @@
 
 	if(nobs){
-		x   = (double*)xmalloc(nobs*sizeof(double));
-		y   = (double*)xmalloc(nobs*sizeof(double));
-		obs = (double*)xmalloc(nobs*sizeof(double));
+		x   = xNew<double>(nobs);
+		y   = xNew<double>(nobs);
+		obs = xNew<double>(nobs);
 		for(int i=0;i<this->Size();i++){
 			observation=(Observation*)this->GetObjectByOffset(i);
@@ -321,7 +321,7 @@
 	/*clean-up*/
 	*pprediction = prediction;
-	xfree((void**)&x);
-	xfree((void**)&y);
-	xfree((void**)&obs);
+	xDelete<double>(x);
+	xDelete<double>(y);
+	xDelete<double>(obs);
 }/*}}}*/
 /*FUNCTION Observations::InterpolationKriging{{{*/
@@ -360,7 +360,7 @@
 
 	/*Allocate intermediary matrix and vectors*/
-	Gamma  = (double*)xmalloc(n_obs*n_obs*sizeof(double));
-	gamma0 = (double*)xmalloc(n_obs*sizeof(double));
-	ones   = (double*)xmalloc(n_obs*sizeof(double));
+	Gamma  = xNew<double>(n_obs*n_obs);
+	gamma0 = xNew<double>(n_obs);
+	ones   = xNew<double>(n_obs);
 
 	/*First: Create semivariogram matrix for observations*/
@@ -401,13 +401,13 @@
 	*pprediction = prediction;
 	*perror = error;
-	xfree((void**)&x);
-	xfree((void**)&y);
-	xfree((void**)&obs);
-	xfree((void**)&Gamma);
-	xfree((void**)&gamma0);
-	xfree((void**)&ones);
-	xfree((void**)&GinvG0);
-	xfree((void**)&Ginv1);
-	xfree((void**)&GinvZ);
+	xDelete<double>(x);
+	xDelete<double>(y);
+	xDelete<double>(obs);
+	xDelete<double>(Gamma);
+	xDelete<double>(gamma0);
+	xDelete<double>(ones);
+	xDelete<double>(GinvG0);
+	xDelete<double>(Ginv1);
+	xDelete<double>(GinvZ);
 
 }/*}}}*/
@@ -445,5 +445,5 @@
 	Observation *observation2 = NULL;
 
-	double *counter = (double*)xmalloc(n*sizeof(double));
+	double *counter = xNew<double>(n);
 	for(j=0;j<n;j++) counter[j] = 0.0;
 	for(j=0;j<n;j++) gamma[j]   = 0.0;
@@ -474,4 +474,4 @@
 
 	/*Assign output pointer*/
-	xfree((void**)&counter);
-}/*}}}*/
+	xDelete<double>(counter);
+}/*}}}*/
Index: /issm/trunk-jpl/src/c/Container/Options.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Options.cpp	(revision 12458)
+++ /issm/trunk-jpl/src/c/Container/Options.cpp	(revision 12459)
@@ -222,5 +222,5 @@
 	else{
 		stringsize=strlen(default_value)+1;
-		outstring=(char*)xmalloc(stringsize*sizeof(char));
+		outstring=xNew<char>(stringsize);
 		memcpy(outstring,default_value,stringsize*sizeof(char));
 		*pvalue=outstring;
@@ -246,5 +246,5 @@
 		if(option->ObjectEnum()==OptionCellEnum){
 			if (option->NumEl()) {
-				*ppvalue=(char **) xmalloc(option->NumEl()*sizeof(char *));
+				*ppvalue=xNew<char*>(option->NumEl());
 				if (numel) *numel=option->NumEl();
 				option->Get(&options);
Index: /issm/trunk-jpl/src/c/Container/Vertices.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Vertices.cpp	(revision 12458)
+++ /issm/trunk-jpl/src/c/Container/Vertices.cpp	(revision 12459)
@@ -60,5 +60,5 @@
 	 * cpus by the total last dofs of the previus cpu, starting from 0.
 	 * First: bet number of dofs for each cpu*/
-	alldofcount=(int*)xmalloc(num_procs*sizeof(int));
+	alldofcount=xNew<int>(num_procs);
 	#ifdef _HAVE_MPI_
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
@@ -83,6 +83,6 @@
 	 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 
 	 * up by their clones: */
-	truedofs   =(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));
-	alltruedofs=(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));
+	truedofs   =xNewZeroInit<int>(numberofobjects*numberofdofsperobject);
+	alltruedofs=xNewZeroInit<int>(numberofobjects*numberofdofsperobject);
 	for (i=0;i<this->Size();i++){
 		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
@@ -102,7 +102,7 @@
 
 	/* Free ressources: */
-	xfree((void**)&alldofcount);
-	xfree((void**)&truedofs);
-	xfree((void**)&alltruedofs);
+	xDelete<int>(alldofcount);
+	xDelete<int>(truedofs);
+	xDelete<int>(alltruedofs);
 }
 /*}}}*/
@@ -117,6 +117,6 @@
 
 	/*Allocate ranks: */
-	ranks=(int*)xmalloc(numberofobjects*sizeof(int));
-	minranks=(int*)xmalloc(numberofobjects*sizeof(int));
+	ranks=xNew<int>(numberofobjects);
+	minranks=xNew<int>(numberofobjects);
 
 	for(i=0;i<numberofobjects;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit.
@@ -143,6 +143,6 @@
 
 	/*Free ressources: */
-	xfree((void**)&ranks); 
-	xfree((void**)&minranks);
+	xDelete<int>(ranks); 
+	xDelete<int>(minranks);
 
 }
