Index: ../trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp
===================================================================
--- ../trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp	(revision 18708)
+++ ../trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp	(revision 18709)
@@ -16,7 +16,7 @@
 	int         transfer_flag;
 	int         penalty_lock;
 	int         hydro_maxiter;
-	int         *elementactive_counter =NULL;
+	int*        elementactive_counter =NULL;
 	bool        isefficientlayer;
 	IssmDouble  sedimentlimit;
 	IssmDouble  penalty_factor;
@@ -59,6 +59,7 @@
 	if(isefficientlayer==1){
 		elementactive_counter=xNewZeroInit<int>(iomodel->numberofelements);
 		parameters->AddObject(new IntVecParam(ElementActiveCounterEnum,elementactive_counter,iomodel->numberofelements));
+		xDelete<int>(elementactive_counter);
 	}
 	
 }/*}}}*/
@@ -684,19 +685,19 @@
 	bool     element_active;
 	bool     old_active;
 	int      penalty_lock;
-	int*     elementactive_counter = NULL;
+	int*     elementactive_counter=NULL;
 	Element* element=NULL;
 
+	femmodel->parameters->FindParam(&elementactive_counter,NULL,ElementActiveCounterEnum);
 	for(int i=0;i<femmodel->elements->Size();i++){
 		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
-		element->parameters->FindParam(&elementactive_counter,NULL,ElementActiveCounterEnum);
 		element->parameters->FindParam(&penalty_lock,HydrologydcPenaltyLockEnum);
 		
 		Input* node_mask_input = element->GetInput(HydrologydcMaskEplactiveNodeEnum); _assert_(node_mask_input);
 		Input* old_active_input = element->GetInput(HydrologydcMaskEplactiveEltEnum); _assert_(old_active_input);
 		old_active_input->GetInputValue(&old_active);
 		
-		if(node_mask_input->Max()>0.) {
+		if(node_mask_input->Max()>0.){
 			element_active = true;
 		}
 		else{
@@ -708,20 +709,23 @@
 		if(elementactive_counter[i]>penalty_lock){
 			element_active = true;
 		}
-		femmodel->parameters->SetParam(elementactive_counter,femmodel->elements->Size(),ElementActiveCounterEnum);
 		element->AddInput(new BoolInput(HydrologydcMaskEplactiveEltEnum,element_active));
 	}
+	femmodel->parameters->SetParam(elementactive_counter,femmodel->elements->Size(),ElementActiveCounterEnum);
+	xDelete<int>(elementactive_counter);
 }/*}}}*/
 
 void HydrologyDCInefficientAnalysis::ResetCounter(FemModel* femmodel){/*{{{*/
 
-	int*     elementactive_counter = NULL;
+	int*     elementactive_counter=NULL;
 	Element* element=NULL;
-	
+
+	femmodel->parameters->FindParam(&elementactive_counter,NULL,ElementActiveCounterEnum);
 	for(int i=0;i<femmodel->elements->Size();i++){
 		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
-		element->parameters->FindParam(&elementactive_counter,NULL,ElementActiveCounterEnum);
-
-		elementactive_counter=0;
-	}
+		
+		elementactive_counter[i]=0;
+	}		
+	femmodel->parameters->SetParam(elementactive_counter,femmodel->elements->Size(),ElementActiveCounterEnum);
+	xDelete<int>(elementactive_counter);
 }/*}}}*/
