Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use malloc instead of calloc
authorthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 8 Aug 2006 09:00:25 +0000 (09:00 +0000)
committerthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 8 Aug 2006 09:00:25 +0000 (09:00 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2696 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/simdag/sd_global.c
src/simdag/sd_link.c
src/simdag/sd_task.c
src/simdag/sd_workstation.c

index 146a3eb..21cda51 100644 (file)
@@ -24,7 +24,7 @@ void SD_init(int *argc, char **argv) {
     xbt_assert0(0, "SD_init() already called");
   }
 
-  sd_global = xbt_new0(s_SD_global_t, 1);
+  sd_global = xbt_new(s_SD_global_t, 1);
   sd_global->workstations = xbt_dict_new();
   sd_global->workstation_count = 0;
   sd_global->workstation_list = NULL;
@@ -124,7 +124,7 @@ SD_task_t* SD_simulate(double how_long)
   INFO0("Starting simulation...");
 
   /* create the array that will be returned */
-  changed_tasks = xbt_new0(SD_task_t, changed_task_capacity);
+  changed_tasks = xbt_new(SD_task_t, changed_task_capacity);
   changed_tasks[0] = NULL;
 
   if (first_time) {
index 33448bf..68bfefc 100644 (file)
@@ -10,7 +10,7 @@ SD_link_t __SD_link_create(void *surf_link, void *data) {
   SD_CHECK_INIT_DONE();
   xbt_assert0(surf_link != NULL, "surf_link is NULL !");
 
-  SD_link_t link = xbt_new0(s_SD_link_t, 1);
+  SD_link_t link = xbt_new(s_SD_link_t, 1);
   link->surf_link = surf_link;
   link->data = data; /* user data */
 
@@ -38,7 +38,7 @@ const SD_link_t*  SD_link_get_list(void) {
   int i;
 
   if (sd_global->link_list == NULL) { /* this is the first time the function is called */
-    sd_global->link_list = xbt_new0(SD_link_t, sd_global->link_count);
+    sd_global->link_list = xbt_new(SD_link_t, sd_global->link_count);
   
     i = 0;
     xbt_dict_foreach(sd_global->links, cursor, key, data) {
index a777596..a19bd49 100644 (file)
@@ -21,7 +21,7 @@ static void __SD_task_destroy_scheduling_data(SD_task_t task);
 SD_task_t SD_task_create(const char *name, void *data, double amount) {
   SD_CHECK_INIT_DONE();
 
-  SD_task_t task = xbt_new0(s_SD_task_t, 1);
+  SD_task_t task = xbt_new(s_SD_task_t, 1);
 
   /* general information */
   task->data = data; /* user data */
@@ -261,7 +261,7 @@ void SD_task_dependency_add(const char *name, void *data, SD_task_t src, SD_task
     THROW2(arg_error, 0, "A dependency already exists between task '%s' and task '%s'",
           SD_task_get_name(src), SD_task_get_name(dst));
 
-  dependency = xbt_new0(s_SD_dependency_t, 1);
+  dependency = xbt_new(s_SD_dependency_t, 1);
 
   if (name != NULL)
     dependency->name = xbt_strdup(name);
@@ -492,14 +492,14 @@ void SD_task_schedule(SD_task_t task, int workstation_nb,
   task->workstation_nb = workstation_nb;
   task->rate = rate;
 
-  task->computation_amount = xbt_new0(double, workstation_nb);
+  task->computation_amount = xbt_new(double, workstation_nb);
   memcpy(task->computation_amount, computation_amount, sizeof(double) * workstation_nb);
 
   int communication_nb = workstation_nb * workstation_nb;
-  task->communication_amount = xbt_new0(double, communication_nb);
+  task->communication_amount = xbt_new(double, communication_nb);
   memcpy(task->communication_amount, communication_amount, sizeof(double) * communication_nb);
 
-  task->workstation_list = xbt_new0(SD_workstation_t, workstation_nb);
+  task->workstation_list = xbt_new(SD_workstation_t, workstation_nb);
   memcpy(task->workstation_list, workstation_list, sizeof(SD_workstation_t) * workstation_nb);
 
   /* update the task state */
@@ -581,7 +581,7 @@ void __SD_task_really_run(SD_task_t task) {
   /* start the task */
 
   /* we have to create a Surf workstation array instead of the SimDag workstation array */
-  surf_workstations = xbt_new0(void*, task->workstation_nb);
+  surf_workstations = xbt_new(void*, task->workstation_nb);
 
   for (i = 0; i < task->workstation_nb; i++) {
     surf_workstations[i] = task->workstation_list[i]->surf_workstation;
@@ -666,7 +666,7 @@ void __SD_task_just_done(SD_task_t task) {
   SD_task_t candidate;
   int candidate_nb = 0;
   int candidate_capacity = 8;
-  SD_task_t *candidates = xbt_new0(SD_task_t, 8);
+  SD_task_t *candidates = xbt_new(SD_task_t, 8);
   int can_start = 1;
 
   __SD_task_set_state(task, SD_DONE);
index 2a7ac43..48d2479 100644 (file)
@@ -10,7 +10,7 @@ SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data) {
   SD_CHECK_INIT_DONE();
   xbt_assert0(surf_workstation != NULL, "surf_workstation is NULL !");
 
-  SD_workstation_t workstation = xbt_new0(s_SD_workstation_t, 1);
+  SD_workstation_t workstation = xbt_new(s_SD_workstation_t, 1);
   workstation->surf_workstation = surf_workstation;
   workstation->data = data; /* user data */
   SD_workstation_set_access_mode(workstation, SD_WORKSTATION_SHARED_ACCESS); /* default mode is shared */
@@ -57,7 +57,7 @@ const SD_workstation_t* SD_workstation_get_list(void) {
   int i;
 
   if (sd_global->workstation_list == NULL) { /* this is the first time the function is called */
-    sd_global->workstation_list = xbt_new0(SD_workstation_t, sd_global->workstation_count);
+    sd_global->workstation_list = xbt_new(SD_workstation_t, sd_global->workstation_count);
   
     i = 0;
     xbt_dict_foreach(sd_global->workstations, cursor, key, data) {
@@ -132,11 +132,9 @@ const char* SD_workstation_get_name(SD_workstation_t workstation) {
 const SD_link_t* SD_route_get_list(SD_workstation_t src, SD_workstation_t dst) {
   SD_CHECK_INIT_DONE();
 
-  static int first_run = 1;
-
-  if (first_run) {
-    sd_global->recyclable_route = xbt_new0(SD_link_t, SD_link_get_number());
-    first_run = 0;
+  if (sd_global->recyclable_route == NULL) {
+    /* first run */
+    sd_global->recyclable_route = xbt_new(SD_link_t, SD_link_get_number());
   }
 
   void *surf_src = src->surf_workstation;