Index: /issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp	(revision 10103)
+++ /issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp	(revision 10104)
@@ -7,26 +7,35 @@
 
 	int  i,numdof,count;
-	int  ndof_list[numnodes];
+	int* ndof_list=NULL;
 	int *doflist = NULL;
 
-	/*First, figure out size of doflist: */
-	numdof=0;
-	for(i=0;i<numnodes;i++){
-		ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation,setenum);
-		numdof+=ndof_list[i];
+
+	if(numnodes){
+
+		/*Allocate:*/
+		ndof_list=(int*)xmalloc(numdof*sizeof(int));
+
+		/*First, figure out size of doflist: */
+		numdof=0;
+		for(i=0;i<numnodes;i++){
+			ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation,setenum);
+			numdof+=ndof_list[i];
+		}
+
+		if(numdof){
+			/*Allocate: */
+			doflist=(int*)xmalloc(numdof*sizeof(int));
+
+			/*Populate: */
+			count=0;
+			for(i=0;i<numnodes;i++){
+				nodes[i]->GetDofList(&doflist[count],approximation,setenum);
+				count+=ndof_list[i];
+			}
+		}
+		else doflist=NULL;
 	}
-
-	if(numdof){
-		/*Allocate: */
-		doflist=(int*)xmalloc(numdof*sizeof(int));
-
-		/*Populate: */
-		count=0;
-		for(i=0;i<numnodes;i++){
-			nodes[i]->GetDofList(&doflist[count],approximation,setenum);
-			count+=ndof_list[i];
-		}
-	}
-	else doflist=NULL;
+	/*Free ressources:*/
+	xfree((void**)&ndof_list);
 
 	return doflist;
Index: /issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp
===================================================================
--- /issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp	(revision 10103)
+++ /issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp	(revision 10104)
@@ -7,43 +7,54 @@
 
 	int  i,j,count,numdof,numgdof;
-	int  ndof_list[numnodes];
-	int  ngdof_list_cumulative[numnodes];
+	int* ndof_list=NULL;
+	int* ngdof_list_cumulative=NULL;
 	int *doflist = NULL;
 
-	/*Get number of dofs per node, and total for this given set*/
-	numdof=0;
-	numgdof=0;
-	for(i=0;i<numnodes;i++){
+	if(numnodes){
+		/*allocate: */
+		ndof_list=(int*)xmalloc(numnodes*sizeof(int));
+		ngdof_list_cumulative=(int*)xmalloc(numnodes*sizeof(int));
 
-		/*Cumulative list= number of dofs before node i*/
-		ngdof_list_cumulative[i]=numgdof;
 
-		/*Number of dofs for node i for given set and for the g set*/
-		ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation,setenum);
-		numgdof    +=nodes[i]->GetNumberOfDofs(approximation,GsetEnum);
-		numdof     +=ndof_list[i];
+		/*Get number of dofs per node, and total for this given set*/
+		numdof=0;
+		numgdof=0;
+		for(i=0;i<numnodes;i++){
+
+			/*Cumulative list= number of dofs before node i*/
+			ngdof_list_cumulative[i]=numgdof;
+
+			/*Number of dofs for node i for given set and for the g set*/
+			ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation,setenum);
+			numgdof    +=nodes[i]->GetNumberOfDofs(approximation,GsetEnum);
+			numdof     +=ndof_list[i];
+		}
+
+		if(numdof){
+			/*Allocate: */
+			doflist=(int*)xmalloc(numdof*sizeof(int));
+
+			/*Populate: */
+			count=0;
+			for(i=0;i<numnodes;i++){
+				nodes[i]->GetLocalDofList(&doflist[count],approximation,setenum);
+				count+=ndof_list[i];
+			}
+
+			/*We now have something like: [0 1 0 2 1 2]. Offset by gsize, to get something like: [0 1 2 4 6 7]:*/
+			count=0;
+			for(i=0;i<numnodes;i++){
+				for(j=0;j<ndof_list[i];j++){
+					doflist[count+j]+=ngdof_list_cumulative[i];
+				}
+				count+=ndof_list[i];
+			}
+		}
+		else doflist=NULL;
 	}
 
-	if(numdof){
-		/*Allocate: */
-		doflist=(int*)xmalloc(numdof*sizeof(int));
-
-		/*Populate: */
-		count=0;
-		for(i=0;i<numnodes;i++){
-			nodes[i]->GetLocalDofList(&doflist[count],approximation,setenum);
-			count+=ndof_list[i];
-		}
-
-		/*We now have something like: [0 1 0 2 1 2]. Offset by gsize, to get something like: [0 1 2 4 6 7]:*/
-		count=0;
-		for(i=0;i<numnodes;i++){
-			for(j=0;j<ndof_list[i];j++){
-				doflist[count+j]+=ngdof_list_cumulative[i];
-			}
-			count+=ndof_list[i];
-		}
-	}
-	else doflist=NULL;
+	/*Free ressources:*/
+	xfree((void**)&ndof_list);
+	xfree((void**)&ngdof_list_cumulative);
 
 	/*CLean-up and return*/
