SG_BEGIN_DECL()
XBT_PUBLIC(size_t) sg_host_count();
-XBT_PUBLIC(const sg_host_t *) sg_host_list(void);
+XBT_PUBLIC(sg_host_t *) sg_host_list(void);
XBT_PUBLIC(size_t) sg_host_extension_create(void(*deleter)(void*));
XBT_PUBLIC(void*) sg_host_extension_get(sg_host_t host, size_t rank);
* @see sg_host_t
* @{
*/
-XBT_PUBLIC(const SD_link_t *) SD_route_get_list(sg_host_t src,
- sg_host_t dst);
+XBT_PUBLIC(SD_link_t *) SD_route_get_list(sg_host_t src, sg_host_t dst);
XBT_PUBLIC(int) SD_route_get_size(sg_host_t src, sg_host_t dst);
XBT_PUBLIC(double) SD_route_get_latency(sg_host_t src, sg_host_t dst);
* \return an array of the \ref SD_link_t composing the route
* \see SD_route_get_size(), SD_link_t
*/
-const SD_link_t *SD_route_get_list(sg_host_t src, sg_host_t dst)
+SD_link_t *SD_route_get_list(sg_host_t src, sg_host_t dst)
{
xbt_dynar_t surf_route;
SD_link_t* list;
* internally).
* \see sg_host_count()
*/
-const sg_host_t *sg_host_list(void) {
+sg_host_t *sg_host_list(void) {
xbt_assert(sg_host_count() > 0, "There is no host!");
return (sg_host_t*)xbt_dynar_to_array(sg_hosts_as_dynar());
}
/* SD initialization */
sg_host_t w1, w2;
- const sg_host_t *workstations;
- const SD_link_t *route;
+ sg_host_t *workstations;
+ SD_link_t *route;
const char *name1;
const char *name2;
int route_size, i, j, k;
printf("Workstation number: %zu, link number: %d\n",
sg_host_count(), sg_link_count());
+ workstations = sg_host_list();
if (argc >= 3) {
if (!strcmp(argv[2], "ONE_LINK")) {
- workstations = sg_host_list();
w1 = workstations[0];
w2 = workstations[1];
name1 = sg_host_get_name(w1);
printf("Route latency = %f, route bandwidth = %f\n",
SD_route_get_latency(w1, w2),
SD_route_get_bandwidth(w1, w2));
+ xbt_free(route);
}
if (!strcmp(argv[2], "FULL_LINK")) {
- workstations = sg_host_list();
list_size = sg_host_count();
for (i = 0; i < list_size; i++) {
w1 = workstations[i];
printf(" Route latency = %f, route bandwidth = %f\n",
SD_route_get_latency(w1, w2),
SD_route_get_bandwidth(w1, w2));
+ xbt_free(route);
}
}
}
"SG_TEST_mem"));
}
}
+ xbt_free(workstations);
SD_exit();
return 0;