Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Match xbt_malloc with xbt_free.
[simgrid.git] / examples / c / app-chainsend / peer.c
index 22991a3..2fd0525 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2020. The SimGrid Team.
+/* Copyright (c) 2012-2022. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -16,7 +16,7 @@ static void peer_join_chain(peer_t p)
   p->total_pieces     = msg->num_pieces;
   XBT_DEBUG("Peer %s got a 'BUILD_CHAIN' message (prev: %s / next: %s)", sg_mailbox_get_name(p->me),
             p->prev ? sg_mailbox_get_name(p->prev) : NULL, p->next ? sg_mailbox_get_name(p->next) : NULL);
-  free(msg);
+  xbt_free(msg);
 }
 
 static void peer_forward_file(peer_t p)
@@ -30,7 +30,7 @@ static void peer_forward_file(peer_t p)
     p->pending_recvs[nb_pending_recvs] = sg_mailbox_get_async(p->me, &received);
     nb_pending_recvs++;
 
-    int idx = sg_comm_wait_any(p->pending_recvs, nb_pending_recvs);
+    ssize_t idx = sg_comm_wait_any(p->pending_recvs, nb_pending_recvs);
     if (idx != -1) {
       XBT_DEBUG("Peer %s got a 'SEND_DATA' message", sg_mailbox_get_name(p->me));
       /* move the last pending comm where the finished one was, and decrement */
@@ -73,10 +73,10 @@ static peer_t peer_init(int argc, char* argv[])
 
 static void peer_delete(peer_t p)
 {
-  free(p->pending_recvs);
-  free(p->pending_sends);
+  xbt_free(p->pending_recvs);
+  xbt_free(p->pending_sends);
 
-  free(p);
+  xbt_free(p);
 }
 
 void peer(int argc, char* argv[])