int COORD_ASR_LEVEL; //Coordinates level
int NS3_ASR_LEVEL; //host node for ns3
-static xbt_dict_t patterns = NULL;
static xbt_dict_t random_value = NULL;
/* Global vars */
return route;
}
-/*Get Latency*/
-static double get_latency(const char *src, const char *dst)
-{
+static double get_latency(const char *src, const char *dst) {
double latency = -1.0;
get_route_latency(src, dst, NULL, &latency, 0);
return latency;
* This fuction is call by "finalize". It allow to finalize the
* AS or routing components. It delete all the structures.
*/
-static void _finalize(AS_t rc)
-{
- if (rc) {
- xbt_dict_cursor_t cursor = NULL;
- char *key;
- AS_t elem;
- xbt_dict_foreach(rc->routing_sons, cursor, key, elem) {
- _finalize(elem);
- }
- xbt_dict_t tmp_sons = rc->routing_sons;
- char *tmp_name = rc->name;
- xbt_dict_free(&tmp_sons);
- xbt_free(tmp_name);
- xbt_assert(rc->finalize, "no defined method \"finalize\" in \"%s\"",
- current_routing->name);
- (*(rc->finalize)) (rc);
- }
+static void finalize_rec(AS_t as) {
+ xbt_dict_cursor_t cursor = NULL;
+ char *key;
+ AS_t elem;
+
+ xbt_dict_foreach(as->routing_sons, cursor, key, elem)
+ finalize_rec(elem);
+
+ xbt_dict_free(&as->routing_sons);
+ xbt_free(as->name);
+ as->finalize(as);
}
/**
* walk through the routing components tree and delete the structures
* by calling the different "finalize" functions in each routing component
*/
-static void finalize(void)
-{
- /* delete recursively all the tree */
- _finalize(global_routing->root);
- /* delete last_route */
- xbt_dynar_free(&(global_routing->last_route));
- /* delete global routing structure */
+static void finalize(void) {
+ finalize_rec(global_routing->root);
+ xbt_dynar_free(&global_routing->last_route);
xbt_free(global_routing);
}
static void routing_parse_cluster(void)
{
char *host_id, *groups, *link_id = NULL;
+ xbt_dict_t patterns = NULL;
s_sg_platf_host_cbarg_t host;
s_sg_platf_link_cbarg_t link;
if (strcmp(struct_cluster->availability_trace, "")
|| strcmp(struct_cluster->state_trace, "")) {
- if (xbt_dict_size(patterns) == 0)
- patterns = xbt_dict_new();
+ patterns = xbt_dict_new();
xbt_dict_set(patterns, "id", xbt_strdup(struct_cluster->id), free);
xbt_dict_set(patterns, "prefix", xbt_strdup(struct_cluster->prefix), free);
xbt_dict_set(patterns, "suffix", xbt_strdup(struct_cluster->suffix), free);
if (strcmp(struct_cluster->availability_trace, "")) {
xbt_dict_set(patterns, "radical", bprintf("%d", i), xbt_free);
char *tmp_availability_file =
- xbt_strdup(struct_cluster->availability_trace);
- xbt_str_varsubst(tmp_availability_file, patterns);
+ xbt_str_varsubst(struct_cluster->availability_trace, patterns);
XBT_DEBUG("\tavailability_file=\"%s\"", tmp_availability_file);
host.power_trace = tmgr_trace_new(tmp_availability_file);
xbt_free(tmp_availability_file);
XBT_DEBUG("\tavailability_file=\"\"");
}
if (strcmp(struct_cluster->state_trace, "")) {
- char *tmp_state_file = xbt_strdup(struct_cluster->state_trace);
- xbt_str_varsubst(tmp_state_file, patterns);
+ char *tmp_state_file =
+ xbt_str_varsubst(struct_cluster->state_trace, patterns);
XBT_DEBUG("\tstate_file=\"%s\"", tmp_state_file);
host.state_trace = tmgr_trace_new(tmp_state_file);
xbt_free(tmp_state_file);
xbt_dynar_free(&radical_elements);
xbt_free(new_suffix);
- if (strcmp(struct_cluster->availability_trace, "")
- || strcmp(struct_cluster->state_trace, ""))
- xbt_dict_free(&patterns);
-
XBT_DEBUG("</AS>");
sg_platf_new_AS_end();
XBT_DEBUG(" ");
+ xbt_dict_free(&patterns); // no op if it were never set
}
-static void routing_parse_postparse(void)
-{
+static void routing_parse_postparse(void) {
xbt_dict_free(&random_value);
- xbt_dict_free(&patterns);
}
static void routing_parse_peer(sg_platf_peer_cbarg_t peer)