From 49966c59fb3d9158a2f60329232215223d2e8308 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 27 Nov 2020 08:11:00 +0100 Subject: [PATCH] Finish replacing calloc with xbt_new0 in example. --- .../c/energy-exec-ptask/energy-exec-ptask.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/c/energy-exec-ptask/energy-exec-ptask.c b/examples/c/energy-exec-ptask/energy-exec-ptask.c index 04bf93a370..984db05cb3 100644 --- a/examples/c/energy-exec-ptask/energy-exec-ptask.c +++ b/examples/c/energy-exec-ptask/energy-exec-ptask.c @@ -52,29 +52,29 @@ static void runner(int argc, char* argv[]) xbt_free(computation_amounts); XBT_INFO("Then, build a parallel task involving only computations and no communication (1 Gflop per node)"); - computation_amounts = (double*)calloc(host_count, sizeof(double)); + computation_amounts = xbt_new0(double, host_count); for (int i = 0; i < host_count; i++) computation_amounts[i] = 1e9; // 1 Gflop sg_actor_parallel_execute(host_count, hosts, computation_amounts, NULL); - free(computation_amounts); + xbt_free(computation_amounts); XBT_INFO("Then, build a parallel task with no computation nor communication (synchro only)"); - computation_amounts = (double*)calloc(host_count, sizeof(double)); - communication_amounts = (double*)calloc(host_count * host_count, sizeof(double)); + computation_amounts = xbt_new0(double, host_count); + communication_amounts = xbt_new0(double, host_count * host_count); sg_actor_parallel_execute(host_count, hosts, computation_amounts, communication_amounts); - free(communication_amounts); - free(computation_amounts); + xbt_free(communication_amounts); + xbt_free(computation_amounts); XBT_INFO("Finally, trick the ptask to do a 'remote execution', on host %s", sg_host_get_name(hosts[1])); - computation_amounts = (double*)calloc(1, sizeof(double)); + computation_amounts = xbt_new0(double, 1); computation_amounts[0] = 1e9; // 1 Gflop sg_host_t remote[1]; remote[0] = hosts[1]; sg_actor_parallel_execute(1, remote, computation_amounts, NULL /* no comm */); - free(computation_amounts); + xbt_free(computation_amounts); XBT_INFO("Goodbye now!"); - free(hosts); + xbt_free(hosts); } int main(int argc, char* argv[]) @@ -93,7 +93,7 @@ int main(int argc, char* argv[]) /* Pick the first host from the platform file */ sg_host_t* all_hosts = sg_host_list(); sg_host_t first_host = all_hosts[0]; - free(all_hosts); + xbt_free(all_hosts); sg_actor_create("test", first_host, runner, 0, NULL); -- 2.20.1