From cf944399509e0838e40a3fab1cd566329ecefff4 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 26 Jun 2016 14:02:28 +0200 Subject: [PATCH] plug a bunch of memleaks in SD examples --- examples/simdag/availability/sd_availability.c | 3 ++- examples/simdag/dag-dotload/sd_dag-dotload.c | 3 ++- examples/simdag/daxload/sd_daxload.c | 9 +++++---- examples/simdag/io/sd_io.c | 11 ++++++----- examples/simdag/ptg-dotload/sd_ptg-dotload.c | 3 ++- examples/simdag/test/sd_test.cpp | 6 +++--- examples/simdag/throttling/sd_throttling.c | 3 ++- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/examples/simdag/availability/sd_availability.c b/examples/simdag/availability/sd_availability.c index 45f0a1679c..c6c053a1d9 100644 --- a/examples/simdag/availability/sd_availability.c +++ b/examples/simdag/availability/sd_availability.c @@ -41,7 +41,7 @@ int main(int argc, char **argv) { SD_init(&argc, argv); SD_create_environment(argv[1]); - const sg_host_t *hosts = sg_host_list(); + sg_host_t *hosts = sg_host_list(); SD_task_t t1 = SD_task_create_comp_seq("t1", NULL, 25000000); SD_task_t c1 = SD_task_create_comm_e2e("c1", NULL, 125000000); @@ -94,5 +94,6 @@ int main(int argc, char **argv) } } SD_exit(); + xbt_free(hosts); return 0; } diff --git a/examples/simdag/dag-dotload/sd_dag-dotload.c b/examples/simdag/dag-dotload/sd_dag-dotload.c index a2006ba092..2f88d5e42c 100644 --- a/examples/simdag/dag-dotload/sd_dag-dotload.c +++ b/examples/simdag/dag-dotload/sd_dag-dotload.c @@ -60,7 +60,7 @@ int main(int argc, char **argv) /* Schedule them all on the first workstation */ XBT_INFO("------------------- Schedule tasks ---------------------------"); - const sg_host_t *ws_list = sg_host_list(); + sg_host_t *ws_list = sg_host_list(); int count = sg_host_count(); xbt_dynar_foreach(dot, cursor, task) { @@ -71,6 +71,7 @@ int main(int argc, char **argv) SD_task_schedulel(task, 1, ws_list[cursor % count]); } } + xbt_free(ws_list); XBT_INFO("------------------- Run the schedule ---------------------------"); SD_simulate(-1); diff --git a/examples/simdag/daxload/sd_daxload.c b/examples/simdag/daxload/sd_daxload.c index 17349494ed..ed2eb41839 100644 --- a/examples/simdag/daxload/sd_daxload.c +++ b/examples/simdag/daxload/sd_daxload.c @@ -64,18 +64,19 @@ int main(int argc, char **argv) /* Schedule them all on the first host */ XBT_INFO("------------------- Schedule tasks ---------------------------"); - const sg_host_t *ws_list = sg_host_list(); + sg_host_t *host_list = sg_host_list(); int hosts_count = sg_host_count(); - qsort((void *) ws_list, hosts_count, sizeof(sg_host_t), name_compare_hosts); + qsort((void *) host_list, hosts_count, sizeof(sg_host_t), name_compare_hosts); xbt_dynar_foreach(dax, cursor, task) { if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) { if (!strcmp(SD_task_get_name(task), "end")) - SD_task_schedulel(task, 1, ws_list[0]); + SD_task_schedulel(task, 1, host_list[0]); else - SD_task_schedulel(task, 1, ws_list[cursor % hosts_count]); + SD_task_schedulel(task, 1, host_list[cursor % hosts_count]); } } + xbt_free(host_list); XBT_INFO("------------------- Run the schedule ---------------------------"); SD_simulate(-1); diff --git a/examples/simdag/io/sd_io.c b/examples/simdag/io/sd_io.c index a04c20b909..e2cdbbc7d8 100644 --- a/examples/simdag/io/sd_io.c +++ b/examples/simdag/io/sd_io.c @@ -21,16 +21,17 @@ int main(int argc, char **argv) /* Set the workstation model to default, as storage is not supported by the ptask_L07 model yet. */ SD_config("host/model", "default"); SD_create_environment(argv[1]); - const sg_host_t *workstations = sg_host_list(); - int total_nworkstations = sg_host_count(); + sg_host_t *hosts = sg_host_list(); + int total_nhosts = sg_host_count(); - for (ctr=0; ctr