Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Implement link names in SimDag.
[simgrid.git] / src / simdag / sd_workstation.c
index f2c7afe..5c25338 100644 (file)
@@ -8,6 +8,7 @@
  */
 SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data) {
   CHECK_INIT_DONE();
+  xbt_assert0(surf_workstation != NULL, "surf_workstation is NULL !");
 
   SD_workstation_data_t sd_data = xbt_new0(s_SD_workstation_data_t, 1); /* workstation private data */
   sd_data->surf_workstation = surf_workstation;
@@ -17,7 +18,7 @@ SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data) {
   workstation->sd_data = sd_data; /* private data */
   
   const char *name = SD_workstation_get_name(workstation);
-  xbt_dict_set(sd_global->workstations, name, workstation, free); /* add the workstation to the dictionary */
+  xbt_dict_set(sd_global->workstations, name, workstation, __SD_workstation_destroy); /* add the workstation to the dictionary */
 
   /* TODO: route */
   return workstation;
@@ -109,19 +110,17 @@ double SD_workstation_get_power(SD_workstation_t workstation) {
 double SD_workstation_get_available_power(SD_workstation_t workstation) {
   CHECK_INIT_DONE();
   xbt_assert0(workstation != NULL, "Invalid parameter");
-  /* TODO */
-  return 0;
-  /*return workstation->available_power;*/
+  return surf_workstation_resource->extension_public->get_available_speed(workstation->sd_data->surf_workstation);
 }
 
 /* Destroys a workstation. The user data (if any) should have been destroyed first.
  */
-void __SD_workstation_destroy(SD_workstation_t workstation) {
+void __SD_workstation_destroy(void *workstation) {
   CHECK_INIT_DONE();
   xbt_assert0(workstation != NULL, "Invalid parameter");
 
-  if (workstation->sd_data != NULL) {
-    xbt_free(workstation->sd_data);
+  if (((SD_workstation_t) workstation)->sd_data != NULL) {
+    xbt_free(((SD_workstation_t) workstation)->sd_data);
   }
   
   /* TODO: route */