From: thiery Date: Tue, 20 Jun 2006 11:37:36 +0000 (+0000) Subject: Remove field name from strucure SD_link_t. X-Git-Tag: v3.3~2951 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/9155a460bc645b1664a3e3acd7a68ba6786f19b2?ds=sidebyside Remove field name from strucure SD_link_t. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2407 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/simdag/private.h b/src/simdag/private.h index 7884ad004c..ba0998ed5b 100644 --- a/src/simdag/private.h +++ b/src/simdag/private.h @@ -20,18 +20,16 @@ extern SD_global_t sd_global; /* Link private data */ typedef struct SD_link_data { void *surf_link; /* surf object */ - char *name; } s_SD_link_data_t; /* Workstation private data */ typedef struct SD_workstation_data { void *surf_workstation; /* surf object */ - /* TODO: route */ } s_SD_workstation_data_t; /* Private functions */ -SD_link_t __SD_link_create(void *surf_link, char *name, void *data); +SD_link_t __SD_link_create(void *surf_link, void *data); void __SD_link_destroy(void *link); SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data); diff --git a/src/simdag/sd_global.c b/src/simdag/sd_global.c index 52c35d5395..c76bb2cfd6 100644 --- a/src/simdag/sd_global.c +++ b/src/simdag/sd_global.c @@ -49,7 +49,7 @@ void SD_create_environment(const char *platform_file) { } xbt_dict_foreach(network_link_set, cursor, name, surf_link) { - __SD_link_create(surf_link, name, NULL); + __SD_link_create(surf_link, NULL); } } @@ -77,7 +77,7 @@ SD_task_t* SD_simulate(double how_long) xbt_dict_foreach(sd_global->links, cursor, name, link) { bandwidth = SD_link_get_current_bandwidth(link); latency = SD_link_get_current_latency(link); - printf("Link name: %s, bandwidth: %f, latency; %f\n", name, bandwidth, latency); + printf("Link name: %s, bandwidth: %f, latency: %f\n", name, bandwidth, latency); } /* test the route between two workstations */ diff --git a/src/simdag/sd_link.c b/src/simdag/sd_link.c index 89eed1065f..971d45a277 100644 --- a/src/simdag/sd_link.c +++ b/src/simdag/sd_link.c @@ -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); } diff --git a/src/simdag/sd_workstation.c b/src/simdag/sd_workstation.c index ed3b9fb98f..3d842eff6b 100644 --- a/src/simdag/sd_workstation.c +++ b/src/simdag/sd_workstation.c @@ -20,7 +20,6 @@ SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data) { const char *name = SD_workstation_get_name(workstation); xbt_dict_set(sd_global->workstations, name, workstation, __SD_workstation_destroy); /* add the workstation to the dictionary */ - /* TODO: route */ return workstation; } @@ -141,7 +140,5 @@ void __SD_workstation_destroy(void *workstation) { xbt_free(((SD_workstation_t) workstation)->sd_data); } - /* TODO: route */ - xbt_free(workstation); }