From 22000124cfde898c839f9581a9088d80b162e0c5 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 18 Apr 2016 15:09:26 +0200 Subject: [PATCH] plug a bunch of memleaks --- examples/msg/cloud-capping/cloud-capping.c | 1 + examples/msg/cloud-masterworker/cloud-masterworker.c | 2 +- examples/msg/cloud-migration/cloud-migration.c | 2 ++ examples/msg/cloud-multicore/cloud-multicore.c | 3 +++ examples/msg/cloud-two-tasks/cloud-two-tasks.c | 5 +++-- examples/msg/properties/properties.c | 10 +++------- examples/msg/synchro/synchro.c | 1 + 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/examples/msg/cloud-capping/cloud-capping.c b/examples/msg/cloud-capping/cloud-capping.c index aef36265ba..c3b0f7dc75 100644 --- a/examples/msg/cloud-capping/cloud-capping.c +++ b/examples/msg/cloud-capping/cloud-capping.c @@ -198,6 +198,7 @@ static int master_main(int argc, char *argv[]) xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar(); msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t); msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t); + xbt_dynar_free(&hosts_dynar); XBT_INFO("# 1. Put a single task on a PM. "); test_one_task(pm0); diff --git a/examples/msg/cloud-masterworker/cloud-masterworker.c b/examples/msg/cloud-masterworker/cloud-masterworker.c index 0137bdfa26..a2ba395330 100644 --- a/examples/msg/cloud-masterworker/cloud-masterworker.c +++ b/examples/msg/cloud-masterworker/cloud-masterworker.c @@ -202,6 +202,7 @@ int main(int argc, char *argv[]) msg_host_t pm = xbt_dynar_get_as(pms, i, msg_host_t); xbt_dynar_push(worker_pms, &pm); } + xbt_dynar_free(&pms); /* Start the master process on the master pm. */ MSG_process_create("master", master_fun, worker_pms, master_pm); @@ -210,7 +211,6 @@ int main(int argc, char *argv[]) XBT_INFO("Bye (simulation time %g)", MSG_get_clock()); xbt_dynar_free(&worker_pms); - xbt_dynar_free(&pms); return !(res == MSG_OK); } diff --git a/examples/msg/cloud-migration/cloud-migration.c b/examples/msg/cloud-migration/cloud-migration.c index 1c92fb5c85..ffb593e890 100644 --- a/examples/msg/cloud-migration/cloud-migration.c +++ b/examples/msg/cloud-migration/cloud-migration.c @@ -56,6 +56,7 @@ static int master_main(int argc, char *argv[]) msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t); msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t); msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t); + xbt_dynar_free(&hosts_dynar); msg_vm_t vm0, vm1; s_vm_params_t params; memset(¶ms, 0, sizeof(params)); @@ -137,6 +138,7 @@ int main(int argc, char *argv[]) xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar(); msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t); + xbt_dynar_free(&hosts_dynar); launch_master(pm0); int res = MSG_main(); diff --git a/examples/msg/cloud-multicore/cloud-multicore.c b/examples/msg/cloud-multicore/cloud-multicore.c index c8ad9f60fc..9e2d68edbd 100644 --- a/examples/msg/cloud-multicore/cloud-multicore.c +++ b/examples/msg/cloud-multicore/cloud-multicore.c @@ -49,6 +49,7 @@ static void test_pm_pin(void) msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t); msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t); msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t); + xbt_dynar_free(&hosts_dynar); struct task_data t1; struct task_data t2; @@ -145,6 +146,7 @@ static void test_vm_pin(void) msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t); // 1 cores msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t); // 2 cores msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t); // 4 cores + xbt_dynar_free(&hosts_dynar); /* set up VMs on PM2 (4 cores) */ msg_vm_t vm0 = MSG_vm_create_core(pm2, "VM0"); @@ -333,6 +335,7 @@ int main(int argc, char *argv[]) msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t); msg_host_t pm1 = xbt_dynar_get_as(hosts_dynar, 1, msg_host_t); msg_host_t pm2 = xbt_dynar_get_as(hosts_dynar, 2, msg_host_t); + xbt_dynar_free(&hosts_dynar); XBT_INFO("%s: %d core(s), %f flops/s per each", MSG_host_get_name(pm0), MSG_host_get_core_number(pm0), MSG_host_get_speed(pm0)); diff --git a/examples/msg/cloud-two-tasks/cloud-two-tasks.c b/examples/msg/cloud-two-tasks/cloud-two-tasks.c index 15c96989c9..dbb462e7ca 100644 --- a/examples/msg/cloud-two-tasks/cloud-two-tasks.c +++ b/examples/msg/cloud-two-tasks/cloud-two-tasks.c @@ -57,6 +57,7 @@ static int master_main(int argc, char *argv[]) { xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar(); msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t); + xbt_dynar_free(&hosts_dynar); msg_vm_t vm0; vm0 = MSG_vm_create_core(pm0, "VM0"); MSG_vm_start(vm0); @@ -93,8 +94,8 @@ int main(int argc, char *argv[]){ MSG_create_environment(argv[1]); xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar(); - msg_host_t pm0 = xbt_dynar_get_as(hosts_dynar, 0, msg_host_t); - launch_master(pm0); + launch_master(xbt_dynar_get_as(hosts_dynar, 0, msg_host_t)); + xbt_dynar_free(&hosts_dynar); int res = MSG_main(); XBT_INFO("Bye (simulation time %g)", MSG_get_clock()); diff --git a/examples/msg/properties/properties.c b/examples/msg/properties/properties.c index 178de370e7..7df8112a64 100644 --- a/examples/msg/properties/properties.c +++ b/examples/msg/properties/properties.c @@ -93,9 +93,7 @@ static int bob(int argc, char *argv[]) int main(int argc, char *argv[]) { - msg_error_t res = MSG_OK; unsigned int i; - xbt_dynar_t hosts; msg_host_t host; MSG_init(&argc, argv); @@ -111,17 +109,15 @@ int main(int argc, char *argv[]) XBT_INFO("There are %d hosts in the environment", MSG_get_host_number()); - hosts = MSG_hosts_as_dynar(); - + xbt_dynar_t hosts = MSG_hosts_as_dynar(); xbt_dynar_foreach(hosts, i, host){ XBT_INFO("Host '%s' runs at %.0f flops/s",MSG_host_get_name(host), MSG_host_get_speed(host)); } + xbt_dynar_free(&hosts); MSG_launch_application(argv[2]); - res = MSG_main(); - - xbt_dynar_free(&hosts); + msg_error_t res = MSG_main(); return res!=MSG_OK; } diff --git a/examples/msg/synchro/synchro.c b/examples/msg/synchro/synchro.c index 9d4e0a9df8..9a464ba2b0 100644 --- a/examples/msg/synchro/synchro.c +++ b/examples/msg/synchro/synchro.c @@ -38,6 +38,7 @@ int main(int argc, char* argv[]) xbt_dynar_t hosts = MSG_hosts_as_dynar(); msg_host_t h = xbt_dynar_get_as(hosts,0,msg_host_t); + xbt_dynar_free(&hosts); sem = MSG_sem_init(1); char** aliceTimes = xbt_new(char*, 9); -- 2.20.1