Index: /issm/trunk-jpl/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/Elements/Penta.cpp	(revision 12457)
+++ /issm/trunk-jpl/src/c/objects/Elements/Penta.cpp	(revision 12458)
@@ -100,5 +100,5 @@
 
 	//deal with PentaRef mother class
-	penta->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));
+	penta->element_type_list=xNew<int>(this->numanalyses);
 	for(i=0;i<this->numanalyses;i++) penta->element_type_list[i]=this->element_type_list[i];
 
@@ -130,5 +130,5 @@
 
 	/*recover objects: */
-	penta->nodes=(Node**)xmalloc(6*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
+	penta->nodes=xNew<Node*>(6); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
 	for(i=0;i<6;i++)penta->nodes[i]=this->nodes[i];
 	penta->matice=(Matice*)penta->hmatice->delivers();
@@ -730,5 +730,5 @@
 
 	/*Allocate: */
-	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+	doflist=xNew<int>(numberofdofs);
 
 	/*Populate: */
@@ -1147,6 +1147,6 @@
 	Input** old_inputs=NULL;
 
-	new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs
-	old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs
+	new_inputs=xNew<Input*>(num_enums/2); //half the enums are for the new inputs
+	old_inputs=xNew<Input*>(num_enums/2); //half the enums are for the old inputs
 
 	for(i=0;i<num_enums/2;i++){
@@ -1164,6 +1164,6 @@
 
 	/*clean up*/
-	xfree((void**)&new_inputs);
-	xfree((void**)&old_inputs);
+	xDelete<Input*>(new_inputs);
+	xDelete<Input*>(old_inputs);
 
 	/*Return output*/
@@ -1399,15 +1399,15 @@
 	if (object_type==ElementEnum){
 		num_inputs=1;
-		base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
+		base_inputs=xNew<Input*>(num_inputs);
 		base_inputs[0]=(Input*)this->inputs->GetInput(enum_type);
 	}
 	else if (object_type==MaterialsEnum){
 		num_inputs=1;
-		base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
+		base_inputs=xNew<Input*>(num_inputs);
 		base_inputs[0]=(Input*)matice->inputs->GetInput(enum_type);
 	}
 	else if (object_type==NodeEnum){
 		num_inputs=3; //only the three upper nodes
-		base_inputs=(Input**)xmalloc(num_inputs*sizeof(Input*));
+		base_inputs=xNew<Input*>(num_inputs);
 		for(i=0;i<num_inputs;i++){
 			base_inputs[i]=(Input*)this->nodes[i]->inputs->GetInput(enum_type);
@@ -1454,5 +1454,5 @@
 
 	/*clean-up and return*/
-	xfree((void**)&base_inputs);
+	xDelete<Input*>(base_inputs);
 }
 /*}}}*/
@@ -1795,5 +1795,5 @@
 	
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -1819,5 +1819,5 @@
 	
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -1859,5 +1859,5 @@
 	
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -2031,8 +2031,8 @@
 
 		/*Allocate output*/
-		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);
 
 		/*populate enums*/
@@ -4269,5 +4269,5 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -4300,5 +4300,5 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -4371,5 +4371,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -4449,5 +4449,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -4868,5 +4868,5 @@
 			_error_("response %s not supported yet",EnumToStringx(responses[resp]));
 	}
-	xfree((void**)&responses);
+	xDelete<int>(responses);
 }
 /*}}}*/
@@ -5133,5 +5133,5 @@
 	/*Clean up and return*/
 cleanup_and_return:
-	xfree((void**)&control_type);
+	xDelete<int>(control_type);
 }
 /*}}}*/
@@ -5176,5 +5176,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -5211,5 +5211,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -7940,5 +7940,5 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -7976,5 +7976,5 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -8009,5 +8009,5 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -8054,5 +8054,5 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -8171,5 +8171,5 @@
 	
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -8254,6 +8254,6 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflistp);
-	xfree((void**)&doflistm);
+	xDelete<int>(doflistp);
+	xDelete<int>(doflistm);
 }
 /*}}}*/
@@ -8354,6 +8354,6 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflistm);
-	xfree((void**)&doflists);
+	xDelete<int>(doflistm);
+	xDelete<int>(doflists);
 }
 /*}}}*/
@@ -8429,5 +8429,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -8522,6 +8522,6 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflistp);
-	xfree((void**)&doflists);
+	xDelete<int>(doflistp);
+	xDelete<int>(doflists);
 }
 /*}}}*/
@@ -8586,5 +8586,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -8690,5 +8690,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -8751,5 +8751,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/objects/Elements/PentaRef.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/Elements/PentaRef.cpp	(revision 12457)
+++ /issm/trunk-jpl/src/c/objects/Elements/PentaRef.cpp	(revision 12458)
@@ -35,5 +35,5 @@
 
 	/*Only allocate pointer*/
-	element_type_list=(int*)xmalloc(nummodels*sizeof(int));
+	element_type_list=xNew<int>(nummodels);
 
 }
@@ -41,5 +41,5 @@
 /*FUNCTION PentaRef::~PentaRef(){{{*/
 PentaRef::~PentaRef(){
-	xfree((void**)&element_type_list);
+	xDelete<int>(element_type_list);
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/Elements/Tria.cpp	(revision 12457)
+++ /issm/trunk-jpl/src/c/objects/Elements/Tria.cpp	(revision 12458)
@@ -82,5 +82,5 @@
 
 	//deal with TriaRef mother class
-	tria->element_type_list=(int*)xmalloc(this->numanalyses*sizeof(int));
+	tria->element_type_list=xNew<int>(this->numanalyses);
 	for(i=0;i<this->numanalyses;i++) tria->element_type_list[i]=this->element_type_list[i];
 
@@ -111,5 +111,5 @@
 
 	/*recover objects: */
-	tria->nodes=(Node**)xmalloc(3*sizeof(Node*)); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
+	tria->nodes=xNew<Node*>(3); //we cannot rely on an analysis_counter to tell us which analysis_type we are running, so we just copy the nodes.
 	for(i=0;i<3;i++)tria->nodes[i]=this->nodes[i];
 	tria->matice=(Matice*)tria->hmatice->delivers();
@@ -974,5 +974,5 @@
 	/*First, figure out size of doflist and create it: */
 	for(i=0;i<3;i++) numberofdofs+=nodes[i]->GetNumberOfDofs(approximation_enum,setenum);
-	doflist=(int*)xmalloc(numberofdofs*sizeof(int));
+	doflist=xNew<int>(numberofdofs);
 
 	/*Populate: */
@@ -1246,6 +1246,6 @@
 	Input** old_inputs=NULL;
 
-	new_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the new inputs
-	old_inputs=(Input**)xmalloc(num_enums/2*sizeof(Input*)); //half the enums are for the old inputs
+	new_inputs=xNew<Input*>(num_enums/2); //half the enums are for the new inputs
+	old_inputs=xNew<Input*>(num_enums/2); //half the enums are for the old inputs
 
 	for(i=0;i<num_enums/2;i++){
@@ -1263,6 +1263,6 @@
 
 	/*clean up and return*/
-	xfree((void**)&new_inputs);
-	xfree((void**)&old_inputs);
+	xDelete<Input*>(new_inputs);
+	xDelete<Input*>(old_inputs);
 	return converged;
 }
@@ -1530,5 +1530,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -1597,5 +1597,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -1862,8 +1862,8 @@
 
 		/*Allocate output*/
-		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);
 
 		/*populate enums*/
@@ -3252,5 +3252,5 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -3291,5 +3291,5 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -3353,5 +3353,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 
 }
@@ -3413,5 +3413,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -3451,5 +3451,5 @@
 
 	/*Clean up and return*/
-	xfree((void**)&control_type);
+	xDelete<int>(control_type);
 }
 /*}}}*/
@@ -3569,5 +3569,5 @@
 	}
 
-	xfree((void**)&responses);
+	xDelete<int>(responses);
 }
 /*}}}*/
@@ -4428,5 +4428,5 @@
 	/*Clean up and return*/
 	delete gauss;
-	xfree((void**)&responses);
+	xDelete<int>(responses);
 	return pe;
 }
@@ -4607,5 +4607,5 @@
 	/*Clean up and return*/
 	delete gauss;
-	xfree((void**)&responses);
+	xDelete<int>(responses);
 	return pe;
 }
@@ -4784,5 +4784,5 @@
 	/*Clean up and return*/
 	delete gauss;
-	xfree((void**)&responses);
+	xDelete<int>(responses);
 	return pe;
 }
@@ -4956,5 +4956,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -4985,5 +4985,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -5295,5 +5295,5 @@
 	/*Free ressources:*/
 	delete gauss;
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
@@ -5323,5 +5323,5 @@
 
 	/*Free ressources:*/
-	xfree((void**)&doflist);
+	xDelete<int>(doflist);
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/objects/Elements/TriaRef.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/Elements/TriaRef.cpp	(revision 12457)
+++ /issm/trunk-jpl/src/c/objects/Elements/TriaRef.cpp	(revision 12458)
@@ -34,5 +34,5 @@
 
 	/*Only allocate pointer*/
-	element_type_list=(int*)xmalloc(nummodels*sizeof(int));
+	element_type_list=xNew<int>(nummodels);
 
 }
@@ -40,5 +40,5 @@
 /*FUNCTION TriaRef::~TriaRef(){{{*/
 TriaRef::~TriaRef(){
-	xfree((void**)&element_type_list);
+	xDelete<int>(element_type_list);
 }
 /*}}}*/
