Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
change the return type of SD_simulate
authorsuter <suter@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 11 Jun 2010 15:27:34 +0000 (15:27 +0000)
committersuter <suter@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 11 Jun 2010 15:27:34 +0000 (15:27 +0000)
  Why convert a dynar into a NULL terminated array?

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7840 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/simdag/simdag.h
src/simdag/sd_global.c

index a050ae0..76a1d4c 100644 (file)
@@ -196,7 +196,7 @@ XBT_PUBLIC(int) SD_task_dependency_exists(SD_task_t src, SD_task_t dst);
 XBT_PUBLIC(void) SD_init(int *argc, char **argv);
 XBT_PUBLIC(void) SD_application_reinit(void);
 XBT_PUBLIC(void) SD_create_environment(const char *platform_file);
 XBT_PUBLIC(void) SD_init(int *argc, char **argv);
 XBT_PUBLIC(void) SD_application_reinit(void);
 XBT_PUBLIC(void) SD_create_environment(const char *platform_file);
-XBT_PUBLIC(SD_task_t *) SD_simulate(double how_long);
+XBT_PUBLIC(xbt_dynar_t) SD_simulate(double how_long);
 XBT_PUBLIC(double) SD_get_clock(void);
 XBT_PUBLIC(void) SD_exit(void);
 XBT_PUBLIC(xbt_dynar_t) SD_daxload(const char*filename);
 XBT_PUBLIC(double) SD_get_clock(void);
 XBT_PUBLIC(void) SD_exit(void);
 XBT_PUBLIC(xbt_dynar_t) SD_daxload(const char*filename);
index aeab84f..b44630c 100644 (file)
@@ -184,14 +184,13 @@ void SD_create_environment(const char *platform_file)
  * \return a NULL-terminated array of \ref SD_task_t whose state has changed.
  * \see SD_task_schedule(), SD_task_watch()
  */
  * \return a NULL-terminated array of \ref SD_task_t whose state has changed.
  * \see SD_task_schedule(), SD_task_watch()
  */
-SD_task_t *SD_simulate(double how_long)
+xbt_dynar_t SD_simulate(double how_long)
 {
   double total_time = 0.0;      /* we stop the simulation when total_time >= how_long */
   double elapsed_time = 0.0;
   SD_task_t task, task_safe, dst;
   SD_dependency_t dependency;
   surf_action_t action;
 {
   double total_time = 0.0;      /* we stop the simulation when total_time >= how_long */
   double elapsed_time = 0.0;
   SD_task_t task, task_safe, dst;
   SD_dependency_t dependency;
   surf_action_t action;
-  SD_task_t *res = NULL;
   xbt_dynar_t changed_tasks = xbt_dynar_new(sizeof(SD_task_t), NULL);
   unsigned int iter, depcnt;
   static int first_time = 1;
   xbt_dynar_t changed_tasks = xbt_dynar_new(sizeof(SD_task_t), NULL);
   unsigned int iter, depcnt;
   static int first_time = 1;
@@ -290,19 +289,12 @@ SD_task_t *SD_simulate(double how_long)
     }
   }
 
     }
   }
 
-  res = xbt_new0(SD_task_t, (xbt_dynar_length(changed_tasks) + 1));
-
-  xbt_dynar_foreach(changed_tasks, iter, task) {
-    res[iter] = task;
-  }
-  xbt_dynar_free(&changed_tasks);
-
   VERB0("Simulation finished");
   DEBUG3("elapsed_time = %f, total_time = %f, watch_point_reached = %d",
          elapsed_time, total_time, sd_global->watch_point_reached);
   DEBUG1("current time = %f", surf_get_clock());
 
   VERB0("Simulation finished");
   DEBUG3("elapsed_time = %f, total_time = %f, watch_point_reached = %d",
          elapsed_time, total_time, sd_global->watch_point_reached);
   DEBUG1("current time = %f", surf_get_clock());
 
-  return res;
+  return changed_tasks;
 }
 
 /**
 }
 
 /**