Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Prefer xbt_malloc that will never return NULL.
[simgrid.git] / teshsuite / smpi / gh-139 / gh-139.c
index 645fad6..e570b8b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019-2020. The SimGrid Team.
+/* Copyright (c) 2019-2021. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@ void* req_wait(void* bar);
 static void thread_create_wrapper(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 {
   int the_global_rank  = global_rank;
-  struct threadwrap* t = (struct threadwrap*)sg_actor_self_data();
+  struct threadwrap* t = (struct threadwrap*)sg_actor_self_get_data();
   XBT_INFO("new thread has parameter rank %d and global variable rank %d", ((struct param*)(t->param))->rank,
            the_global_rank);
   SMPI_thread_create();
@@ -40,17 +40,17 @@ static void thread_create_wrapper(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED
 
 static void mpi_thread_create(const char* name, void* (*f)(void*), void* param)
 {
-  struct threadwrap* threadwrap = (struct threadwrap*)malloc(sizeof(*threadwrap));
+  struct threadwrap* threadwrap = xbt_malloc(sizeof(*threadwrap));
   threadwrap->f                 = f;
   threadwrap->param             = param;
   sg_actor_t actor              = sg_actor_init(name, sg_host_self());
-  sg_actor_data_set(actor, threadwrap);
+  sg_actor_set_data(actor, threadwrap);
   sg_actor_start(actor, thread_create_wrapper, 0, NULL);
 }
 
 static void mythread_create(const char* name, MPI_Request* req, int rank)
 {
-  struct param* param = (struct param*)malloc(sizeof(*param));
+  struct param* param = xbt_malloc(sizeof(*param));
   param->req          = req;
   param->rank         = rank;
   mpi_thread_create(name, req_wait, param);