Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference local variables in examples/.
[simgrid.git] / examples / s4u / energy-link / s4u-energy-link.cpp
index e765771..f16d10e 100644 (file)
@@ -27,7 +27,6 @@ static void sender(std::vector<std::string> args)
   /* Sleep a while before starting the example */
   simgrid::s4u::this_actor::sleep_for(10);
 
-
   if (flow_amount == 1) {
     /* - Send the task to the @ref worker */
     char* payload = bprintf("%f", comm_size);
@@ -54,7 +53,7 @@ static void receiver(std::vector<std::string> args)
     void* res = mailbox->get();
     xbt_free(res);
   } else {
-    void* data[flow_amount];
+    void** data= new void*[flow_amount];
 
     // Start all comms in parallel, and wait for their completion in one shot
     std::vector<simgrid::s4u::CommPtr> comms;
@@ -64,13 +63,13 @@ static void receiver(std::vector<std::string> args)
     simgrid::s4u::Comm::wait_all(&comms);
     for (int i = 0; i < flow_amount; i++)
       xbt_free(data[i]);
+    delete[] data;
   }
   XBT_INFO("receiver done.");
 }
 
 int main(int argc, char* argv[])
 {
-
   simgrid::s4u::Engine e(&argc, argv);
 
   XBT_INFO("Activating the SimGrid link energy plugin");
@@ -91,6 +90,7 @@ int main(int argc, char* argv[])
     argSender.push_back("1"); // Default value
     argReceiver.push_back("1");
   }
+
   if (argc > 3) {
     if (strcmp(argv[3], "random") == 0) { // We're asked to get a random size
       /* Initialize the random number generator */