Index: /issm/trunk-jpl/src/c/shared/Alloc/alloc.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Alloc/alloc.cpp	(revision 13247)
+++ /issm/trunk-jpl/src/c/shared/Alloc/alloc.cpp	(revision 13248)
@@ -26,30 +26,4 @@
 #include "../../include/include.h"
 #include "../../classes/objects/objects.h"
-
-void* xmalloc(int size){
-
-	void* memptr=NULL;
-
-	if(!size)_error_("attempting to 0 size allocation!");
-
-	/* Use the c library to do the allocation: */
-	memptr=malloc(size);
-	if(!memptr) _error_("memory allocation failed!");
-
-	return memptr;
-}
-
-void* xcalloc(int n,int size){
-
-	void* memptr=NULL;
-	
-	if(!size)_error_("attempting to 0 size allocation!");
-
-	/* Use the c library to do the allocation: */
-	memptr=calloc(n,size);
-	if(!memptr) _error_("memory allocation failed!");
-
-	return memptr;
-}
 
 void xfree(void* *pv){
@@ -83,15 +57,2 @@
 	}
 }
-
-void* xrealloc( void* pv, int size){
-	
-	register void* value=NULL;
-	
-	if(!size)_error_("attempting to realloc to zero");
-	value = (void*)realloc(pv,size);
-
-	if (value == NULL) {
-		_error_("virtual memory exhausted");
-	}
-	return value;
-}
Index: /issm/trunk-jpl/src/c/shared/Alloc/alloc.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Alloc/alloc.h	(revision 13247)
+++ /issm/trunk-jpl/src/c/shared/Alloc/alloc.h	(revision 13248)
@@ -10,12 +10,8 @@
 template <class doubletype> class Matrix;
 template <class doubletype> class Vector;
-void* xmalloc(int size);
-void* xcalloc(int n,int size);
-void  xfree(void** pvptr);
-void* xrealloc ( void* pv, int size);
+void xfree(void** pvptr);
 void xdelete(Matrix<IssmDouble>** pvptr);
 void xdelete(Vector<IssmDouble>** pvptr);
 
 #include "./xNewDelete.h"
-
 #endif
Index: /issm/trunk-jpl/src/c/shared/Alloc/xNewDelete.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Alloc/xNewDelete.h	(revision 13247)
+++ /issm/trunk-jpl/src/c/shared/Alloc/xNewDelete.h	(revision 13248)
@@ -61,34 +61,34 @@
 T* xReNew(T* old, unsigned int old_size, unsigned int size) {
 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES
-  T* aT_p=0;
-  if (!old) { // no old memory
-    if (size)  
-      aT_p=xNew<T>(size); // according to realloc behavior in manual page 
-  }
-  else { // have old memory
-    if (!size)  // but 0 size
-      xDelete<T>(old); // according to realloc behavior in manual page
-    else { // non-zero size
-      assert(old_size); // have old memory - need to have old_size set or this call is bad
-      // allocate new, delete old; ; even for the case when size is 
-      // less than old_size we can't just keep the memory unchanged 
-      // because otherwise classes that have ctors/dtors with side-effects 
-      // may misbehave, for example classes with static instance/operations counters. 
-      aT_p=xNew<T>(size);
-      unsigned int iMax=(old_size<size)?old_size:size;
-      for (unsigned int i=0; i<iMax;++i) { 
-	// we need to copy the items by explicit assignments
-	aT_p[i]=old[i];
-      }
-      xDelete<T>(old);
-    }
-  }
-  return aT_p;
+	T* aT_p=0;
+	if (!old) { // no old memory
+		if (size)  
+		 aT_p=xNew<T>(size); // according to realloc behavior in manual page 
+	}
+	else { // have old memory
+		if (!size)  // but 0 size
+		 xDelete<T>(old); // according to realloc behavior in manual page
+		else { // non-zero size
+			assert(old_size); // have old memory - need to have old_size set or this call is bad
+			// allocate new, delete old; ; even for the case when size is 
+			// less than old_size we can't just keep the memory unchanged 
+			// because otherwise classes that have ctors/dtors with side-effects 
+			// may misbehave, for example classes with static instance/operations counters. 
+			aT_p=xNew<T>(size);
+			unsigned int iMax=(old_size<size)?old_size:size;
+			for (unsigned int i=0; i<iMax;++i) { 
+				// we need to copy the items by explicit assignments
+				aT_p[i]=old[i];
+			}
+			xDelete<T>(old);
+		}
+	}
+	return aT_p;
 #else
-  T* aT_p=0;
-  aT_p=(T*)realloc((void*)old,size*sizeof(T));
-  if (size) 
-    assert(aT_p); // according to realloc behavior in manual page
-  return aT_p;
+	T* aT_p=0;
+	aT_p=(T*)realloc((void*)old,size*sizeof(T));
+	if (size) 
+	 assert(aT_p); // according to realloc behavior in manual page
+	return aT_p;
 #endif 
 }
Index: /issm/trunk-jpl/src/c/shared/TriMesh/SplitMeshForRifts.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/TriMesh/SplitMeshForRifts.cpp	(revision 13247)
+++ /issm/trunk-jpl/src/c/shared/TriMesh/SplitMeshForRifts.cpp	(revision 13248)
@@ -76,12 +76,13 @@
 				 instances of node in the triangulation *for those elements, to the
 				 new node.*/
-				
+
+				//create new node
+				x=xReNew<double>(x,nods,nods+1);
+				y=xReNew<double>(y,nods,nods+1);
+				x[nods]=x[node-1]; //matlab indexing
+				y[nods]=y[node-1]; //matlab indexing
+
 				//augment number of nodes 
-				nods=nods+1;
-				//create new node
-				x=(double*)xrealloc(x,nods*sizeof(double));
-				y=(double*)xrealloc(y,nods*sizeof(double));
-				x[nods-1]=x[node-1]; //matlab indexing
-				y[nods-1]=y[node-1]; //matlab indexing
+				nods++;
 
 				//change elements owning this node
Index: /issm/trunk-jpl/src/c/shared/TriMesh/TriMeshUtils.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 13247)
+++ /issm/trunk-jpl/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 13248)
@@ -265,6 +265,6 @@
 
 	/*Reallocate segments: */
-	segments=(double*)xrealloc(segments,(nsegs+nriftsegs)*3*sizeof(double));
-	segmentmarkerlist=(double*)xrealloc(segmentmarkerlist,(nsegs+nriftsegs)*sizeof(double));
+	segments         =xReNew<double>(segments,         nsegs*3,(nsegs+nriftsegs)*3);
+	segmentmarkerlist=xReNew<double>(segmentmarkerlist,nsegs*3,(nsegs+nriftsegs)*3);
 
 	/*First, update the existing segments to the new nodes :*/
@@ -662,6 +662,6 @@
 
 	/*Reallocate x and y: */
-	xreal=(double*)xrealloc(x,newnods*sizeof(double));
-	yreal=(double*)xrealloc(y,newnods*sizeof(double));
+	xreal=xReNew<double>(x,nods,newnods);
+	yreal=xReNew<double>(y,nods,newnods);
 	counter1=0;
 	counter2=0;
@@ -1093,10 +1093,9 @@
 				if(triple==1){
 					/*el is a corner element: we need to split it in 3 triangles: */
-					x=(double*)xrealloc(x,(nods+1)*sizeof(double));
-					y=(double*)xrealloc(y,(nods+1)*sizeof(double));
+					x=xReNew<double>(x,nods,nods+1);
+					y=xReNew<double>(y,nods,nods+1);
 					x[nods]=(x[(int)node1-1]+x[(int)node2-1]+x[(int)node3-1])/3;
 					y[nods]=(y[(int)node1-1]+y[(int)node2-1]+y[(int)node3-1])/3;
-
-					index=(double*)xrealloc(index,(nel+2)*3*sizeof(double));
+					index=xReNew<double>(index,nel*3,(nel+2*3));
 					/*First, reassign element el: */
 					*(index+3*el+0)=node1;
