#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;
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.
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);
}