Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / src / smpi / colls / bcast / bcast-flattree.cpp
index b77a186..8b367f3 100644 (file)
@@ -1,18 +1,15 @@
-/* Copyright (c) 2013-2014. The SimGrid Team.
+/* Copyright (c) 2013-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. */
 
-#include "../colls_private.h"
-
-int
-Coll_bcast_flattree::bcast(void *buff, int count, MPI_Datatype data_type,
-                               int root, MPI_Comm comm)
+#include "../colls_private.hpp"
+namespace simgrid {
+namespace smpi {
+int bcast__flattree(void *buff, int count, MPI_Datatype data_type,
+                    int root, MPI_Comm comm)
 {
-  MPI_Request *req_ptr;
-  MPI_Request *reqs;
-
   int i, rank, num_procs;
   int tag = COLL_TAG_BCAST;
 
@@ -24,8 +21,8 @@ Coll_bcast_flattree::bcast(void *buff, int count, MPI_Datatype data_type,
   }
 
   else {
-    reqs = (MPI_Request *) xbt_malloc((num_procs - 1) * sizeof(MPI_Request));
-    req_ptr = reqs;
+    MPI_Request* reqs    = new MPI_Request[num_procs - 1];
+    MPI_Request* req_ptr = reqs;
 
     // Root sends data to all others
     for (i = 0; i < num_procs; i++) {
@@ -37,7 +34,10 @@ Coll_bcast_flattree::bcast(void *buff, int count, MPI_Datatype data_type,
     // wait on all requests
     Request::waitall(num_procs - 1, reqs, MPI_STATUSES_IGNORE);
 
-    free(reqs);
+    delete[] reqs;
   }
   return MPI_SUCCESS;
 }
+
+}
+}