Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove field name from strucure SD_link_t.
[simgrid.git] / src / simdag / sd_link.c
index 89eed10..971d45a 100644 (file)
@@ -1,28 +1,23 @@
 #include "private.h"
 #include "simdag/simdag.h"
+#include "xbt/dict.h"
+#include "xbt/sysdep.h"
 #include "surf/surf.h"
-#include "xbt/sysdep.h" /* xbt_new0 */
 
 /* Creates a link.
  */
-SD_link_t __SD_link_create(void *surf_link, char *name, void *data) {
+SD_link_t __SD_link_create(void *surf_link, void *data) {
   CHECK_INIT_DONE();
   xbt_assert0(surf_link != NULL, "surf_link is NULL !");
-  xbt_assert0(name != NULL, "name is NULL !");
 
   SD_link_data_t sd_data = xbt_new0(s_SD_link_data_t, 1); /* link private data */
   sd_data->surf_link = surf_link;
-  sd_data->name = xbt_strdup(name);
 
   SD_link_t link = xbt_new0(s_SD_link_t, 1);
   link->sd_data = sd_data; /* private data */
   link->data = data; /* user data */
 
-  /*link->capacity = capacity;*/
-  /* link->current_bandwidth = bandwidth;
-     link->current_latency = latency;*/
-
-  /*xbt_dynar_push(sd_global->links, link);*/
+  const char *name = SD_link_get_name(link);
   xbt_dict_set(sd_global->links, name, link, __SD_link_destroy); /* add the workstation to the dictionary */
 
   return link;
@@ -44,14 +39,12 @@ void SD_link_set_data(SD_link_t link, void *data) {
   link->data = data;
 }
 
-/* Returns the name of a link. The name can be NULL.
+/* Returns the name of a link. The name cannot be NULL.
  */
 const char* SD_link_get_name(SD_link_t link) {
   CHECK_INIT_DONE();
   xbt_assert0(link != NULL, "Invalid parameter");
-  return link->sd_data->name;
-
-  /*  return surf_network_resource->common_public->get_resource_name(link->sd_data->surf_link);*/
+  return surf_workstation_resource->extension_public->get_link_name(link->sd_data->surf_link);
 }
 
 /* Returns the capacity of a link.
@@ -86,9 +79,6 @@ void __SD_link_destroy(void *link) {
 
   SD_link_data_t sd_data = ((SD_link_t) link)->data;
   if (sd_data != NULL) {
-    if (sd_data->name != NULL)
-      xbt_free(sd_data->name);
-  
     xbt_free(sd_data);
   }