Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix a memleak
[simgrid.git] / teshsuite / s4u / ns3-simultaneous-send-rcv / ns3-simultaneous-send-rcv.cpp
index b7a4de5..e087d39 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -33,8 +33,10 @@ static void test_send(){
 static void test_receive(){
   for (int nb_message = 0; nb_message < nb_message_to_send * nb_sender; nb_message++) {
     XBT_VERB("waiting for messages");
-    int id = *(int*)(box->get());
+    int* ptr = (int*)(box->get());
+    int id   = *ptr;
     XBT_VERB("received messages #%i", id);
+    delete ptr;
   }
   XBT_INFO("Done receiving from %d senders, each of them sending %d messages", nb_sender, nb_message_to_send);
 }