Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Please cppcheck.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 4 Dec 2020 16:06:36 +0000 (17:06 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 4 Dec 2020 16:06:36 +0000 (17:06 +0100)
examples/smpi/ampi_test/ampi_test.cpp

index bc02cad..696f27a 100644 (file)
@@ -12,8 +12,11 @@ int main(int argc, char* argv[])
   MPI_Init(&argc, &argv);
   // useless alocations for testing and coverage
   void* pointer = malloc(100 * sizeof(int));
-  pointer       = realloc(pointer, 50 * sizeof(int));
-  pointer       = realloc(pointer, 200 * sizeof(int));
+  void* ptmp;
+  if ((ptmp = realloc(pointer, 50 * sizeof(int))) != NULL)
+    pointer = ptmp;
+  if ((ptmp = realloc(pointer, 200 * sizeof(int))) != NULL)
+    pointer = ptmp;
   free(pointer);
   pointer = calloc(100, sizeof(int));
   int rank;