xbt_dynar_t back_route = NULL;
int constraints_per_variable = 0;
- xbt_dynar_t route = global_routing->get_route(src_name, dst_name);
+ // I will need this route for some time so let's call get_route_no_cleanup
+ xbt_dynar_t route = global_routing->get_route_no_cleanup(src_name, dst_name);
+
if (sg_network_fullduplex == 1) {
back_route = global_routing->get_route(dst_name, src_name);
strncpy(action->dst_name, dst_name, strlen(dst_name) + 1);
#endif
+ xbt_dynar_free(&route);
XBT_OUT;
return (surf_action_t) action;
xbt_dict_t where_network_elements; /* char* -> network_element_info_t */
void *loopback;
size_t size_of_link;
- xbt_dynar_t(*get_route) (const char *src, const char *dst);
+ const xbt_dynar_t(*get_route) (const char *src, const char *dst);
+ xbt_dynar_t(*get_route_no_cleanup) (const char *src, const char *dst);
xbt_dynar_t(*get_onelink_routes) (void);
e_surf_network_element_type_t(*get_network_element_type) (const char
*name);
* \param dst the destination host name
*
* walk through the routing components tree and find a route between hosts
- * by calling the differents "get_route" functions in each routing component
+ * by calling the differents "get_route" functions in each routing component.
+ * No need to free the returned dynar. It will be freed at the next call.
*/
-static xbt_dynar_t get_route(const char *src, const char *dst)
+static const xbt_dynar_t get_route(const char *src, const char *dst)
{
route_extended_t e_route;
return global_routing->last_route;
}
+/**
+ * \brief Generic method: find a route between hosts
+ *
+ * \param src the source host name
+ * \param dst the destination host name
+ *
+ * walk through the routing components tree and find a route between hosts
+ * by calling the differents "get_route" functions in each routing component.
+ * Leaves the caller the responsability to clean the returned dynar.
+ */
+static xbt_dynar_t get_route_no_cleanup(const char *src, const char *dst)
+{
+ xbt_dynar_t d = get_route(src,dst);
+ global_routing->last_route = NULL;
+ return d;
+}
+
/**
* \brief Recursive function for finalize
*
global_routing->where_network_elements = xbt_dict_new();
global_routing->root = NULL;
global_routing->get_route = get_route;
+ global_routing->get_route_no_cleanup = get_route_no_cleanup;
global_routing->get_onelink_routes = get_onelink_routes;
global_routing->get_network_element_type = get_network_element_type;
global_routing->finalize = finalize;