Description: fix compilation with gcc-4.9
Bug-Debian: https://bugs.debian.org/746923
Forwarded: https://github.com/Kitware/VTK/pull/7
Author: Anton Gladky <gladk@debian.org>
Last-Update: 2014-05-30
--- a/Filters/ParallelMPI/vtkDistributedDataFilter.cxx
+++ b/Filters/ParallelMPI/vtkDistributedDataFilter.cxx
@@ -1113,7 +1113,10 @@
   vtkIdType cellsPerNode = numTotalCells / nprocs;
 
   vtkIdList **sendCells = new vtkIdList * [ nprocs ];
-  memset(sendCells, 0, sizeof(vtkIdList *) * nprocs);
+  
+  if (sizeof(vtkIdList *) * nprocs > 0) {
+    memset(sendCells, 0, sizeof(vtkIdList *) * nprocs);
+  }
 
   if (numConsumers == nprocs - 1)
   {
@@ -1598,7 +1601,9 @@
   // Exchange int arrays
 
   float **recvArrays = new float * [nprocs];
-  memset(recvArrays, 0, sizeof(float *) * nprocs);
+  if (sizeof(float *) * nprocs > 0) {
+    memset(recvArrays, 0, sizeof(float *) * nprocs);
+  }
 
   if (sendSize[me] > 0)  // sent myself an array
   {
@@ -1720,7 +1725,9 @@
   // Exchange int arrays
 
   vtkIdType **recvArrays = new vtkIdType * [nprocs];
-  memset(recvArrays, 0, sizeof(vtkIdType *) * nprocs);
+  if (sizeof(vtkIdType *) * nprocs > 0) {
+    memset(recvArrays, 0, sizeof(vtkIdType *) * nprocs);
+  }
 
   if (sendSize[me] > 0)  // sent myself an array
   {
@@ -2789,7 +2796,9 @@
 
   unsigned char *vals = new unsigned char [npoints];
 
-  memset(vals, val, npoints);
+  if (npoints > 0) {
+    memset(vals, val, npoints);
+  }
 
   vtkUnsignedCharArray *Array = vtkUnsignedCharArray::New();
   Array->SetName(arrayName);
@@ -2809,7 +2818,9 @@
 
   unsigned char *vals = new unsigned char [ncells];
 
-  memset(vals, val, ncells);
+  if (ncells > 0) {
+    memset(vals, val, ncells);
+  }
 
   vtkUnsignedCharArray *Array = vtkUnsignedCharArray::New();
   Array->SetName(arrayName);
@@ -3008,7 +3019,9 @@
   vtkIdType nGridPoints = grid->GetNumberOfPoints();
 
   vtkIdType *numPointsOutside = new vtkIdType [nprocs];
-  memset(numPointsOutside, 0, sizeof(vtkIdType) * nprocs);
+  if (sizeof(vtkIdType) * nprocs > 0) {
+    memset(numPointsOutside, 0, sizeof(vtkIdType) * nprocs);
+  }
 
   vtkIdTypeArray *globalIds = vtkIdTypeArray::New();
   globalIds->SetNumberOfValues(nGridPoints);
@@ -3090,10 +3103,16 @@
   // global ID back?
 
   vtkFloatArray **ptarrayOut = new vtkFloatArray * [nprocs];
-  memset(ptarrayOut, 0, sizeof(vtkFloatArray *) * nprocs);
+  
+  if (sizeof(vtkFloatArray *) * nprocs > 0) {
+    memset(ptarrayOut, 0, sizeof(vtkFloatArray *) * nprocs);
+  }
 
   vtkIdTypeArray **localIds     = new vtkIdTypeArray * [nprocs];
-  memset(localIds, 0, sizeof(vtkIdTypeArray *) * nprocs);
+  
+  if (sizeof(vtkIdTypeArray *) * nprocs > 0) {
+    memset(localIds, 0, sizeof(vtkIdTypeArray *) * nprocs);
+  }
 
   vtkIdType *next = new vtkIdType [nprocs];
   vtkIdType *next3 = new vtkIdType [nprocs];
@@ -3268,7 +3287,9 @@
   {
     // There are no cells in my assigned region
 
-    memset(gids, 0, sizeof(vtkIdTypeArray *) * nprocs);
+    if (sizeof(vtkIdTypeArray *) * nprocs > 0) {
+      memset(gids, 0, sizeof(vtkIdTypeArray *) * nprocs);
+    }
 
     return gids;
   }
@@ -3473,7 +3494,10 @@
   std::multimap<int, int>::iterator mapIt;
 
   vtkIdTypeArray **processList = new vtkIdTypeArray * [nprocs];
-  memset(processList, 0, sizeof (vtkIdTypeArray *) * nprocs);
+
+  if (sizeof (vtkIdTypeArray *) * nprocs > 0) {
+    memset(processList, 0, sizeof (vtkIdTypeArray *) * nprocs);
+  }
 
   for (int i=0; i<nprocs; i++)
   {
@@ -3563,7 +3587,9 @@
   vtkIdType numPoints = grid->GetNumberOfPoints();
 
   vtkIdTypeArray **ghostPtIds = new vtkIdTypeArray * [nprocs];
-  memset(ghostPtIds, 0, sizeof(vtkIdTypeArray *) * nprocs);
+  if (sizeof(vtkIdTypeArray *) * nprocs) {
+    memset(ghostPtIds, 0, sizeof(vtkIdTypeArray *) * nprocs);
+  }
 
   if (numPoints < 1)
   {
