Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update destructors and test access to surf structures
authorthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 15 Jun 2006 15:56:00 +0000 (15:56 +0000)
committerthiery <thiery@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 15 Jun 2006 15:56:00 +0000 (15:56 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2382 48e7efb5-ca39-0410-a469-dd3cf9ba447f

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

index 985797b..89edfed 100644 (file)
@@ -37,10 +37,8 @@ void SG_create_environment(const char *platform_file) {
 
   /* now let's create the SG wrappers */
   xbt_dict_foreach(workstation_set, cursor, name, workstation) {
-    
     __SG_workstation_create(name, workstation, NULL);
   }
-
 }
 
 /* Launches the simulation. Returns a NULL-terminated array of SG_task_t whose state has changed.
@@ -48,6 +46,20 @@ void SG_create_environment(const char *platform_file) {
 SG_task_t* SG_simulate(double how_long)
 {
   /* TODO */
+
+  /* temporary test to access to the surf workstation structure */
+  xbt_dict_cursor_t cursor = NULL;
+  char *name = NULL;
+  void *workstation = NULL;
+  const char *surf_name;
+  int speed;
+
+  xbt_dict_foreach(workstation_set, cursor, name, workstation) {
+    surf_name = surf_workstation_resource->common_public->get_resource_name(workstation);
+    speed = surf_workstation_resource->extension_public->get_speed(workstation, 1.0);
+    printf("Workstation name: %s, Surf name: %s, speed: %d\n", name, surf_name, speed);
+  }
+
   return NULL;
 }
 
index fcfc578..e130213 100644 (file)
@@ -28,7 +28,7 @@ void* SG_link_get_data(SG_link_t link) {
   return link->data;
 }
 
-/* Sets the user data of a link. The data can be NULL.
+/* Sets the user data of a link. The new data can be NULL. The old data should have been freed first if it was not NULL.
  */
 void SG_link_set_data(SG_link_t link, void *data) {
   xbt_assert0(link, "Invalid parameter");
@@ -75,7 +75,10 @@ double SG_link_get_current_latency(SG_link_t link) {
 void __SG_link_destroy(SG_link_t link) {
   xbt_assert0(link, "Invalid parameter");
 
-  if (link->name)
+  if (link->sgdata != NULL)
+    xbt_free(link->sgdata);
+  
+  if (link->name != NULL)
     xbt_free(link->name);
 
   xbt_free(link);
index 42b93b4..0c3ab6e 100644 (file)
@@ -56,14 +56,14 @@ int SG_workstation_get_number(void) {
   return sg_global->workstation_count;
 }
 
-/* Sets the data of a workstation.
+/* Sets the data of a workstation. The new data can be NULL. The old data should have been freed first if it was not NULL.
  */
 void SG_workstation_set_data(SG_workstation_t workstation, void *data) {
   xbt_assert0(workstation != NULL, "Invalid parameter");
   workstation->data = data;
 }
 
-/* Returns the data of a workstation.
+/* Returns the data of a workstation. The user data can be NULL.
  */
 void* SG_workstation_get_data(SG_workstation_t workstation) {
   xbt_assert0(workstation != NULL, "Invalid parameter");
@@ -74,8 +74,7 @@ void* SG_workstation_get_data(SG_workstation_t workstation) {
  */
 const char* SG_workstation_get_name(SG_workstation_t workstation) {
   xbt_assert0(workstation != NULL, "Invalid parameter");
-  return NULL;
-  /*  return workstation->name;*/
+  return workstation->name;
 }
 
 SG_link_t* SG_workstation_route_get_list(SG_workstation_t src, SG_workstation_t dst) {
@@ -111,9 +110,12 @@ double SG_workstation_get_available_power(SG_workstation_t workstation) {
 void __SG_workstation_destroy(SG_workstation_t workstation) {
   xbt_assert0(workstation != NULL, "Invalid parameter");
 
-  SG_workstation_data_t sgdata = workstation->sgdata;
-  if (sgdata != NULL) {
-    xbt_free(sgdata);
+  if (workstation->sgdata != NULL) {
+    xbt_free(workstation->sgdata);
+  }
+  
+  if (workstation->name != NULL) {
+    xbt_free(workstation->name);
   }
   
   /* TODO: route */