current_routing->p_hierarchy = SURF_ROUTING_BASE;
simgrid::surf::NetCard *netcard =
- new simgrid::surf::NetCardImpl(xbt_strdup(host->id), -1, SURF_NETWORK_ELEMENT_HOST, current_routing);
+ new simgrid::surf::NetCardImpl(host->id, SURF_NETWORK_ELEMENT_HOST, current_routing);
netcard->setId(current_routing->parsePU(netcard));
sg_host_t h = simgrid::s4u::Host::by_name_or_create(host->id);
"Reading a router, processing unit \"%s\" already exists",
router->id);
- simgrid::surf::NetCard *info = new simgrid::surf::NetCardImpl(
- xbt_strdup(router->id), -1, SURF_NETWORK_ELEMENT_ROUTER, current_routing);
+ simgrid::surf::NetCard *info = new simgrid::surf::NetCardImpl(router->id, SURF_NETWORK_ELEMENT_ROUTER, current_routing);
info->setId(current_routing->parsePU(info));
xbt_lib_set(as_router_lib, router->id, ROUTING_ASR_LEVEL, (void *) info);
XBT_DEBUG("Having set name '%s' id '%d'", router->id, info->getId());
new_as->p_hierarchy = SURF_ROUTING_NULL;
new_as->p_name = xbt_strdup(AS->id);
- simgrid::surf::NetCard *info =
- new simgrid::surf::NetCardImpl(xbt_strdup(new_as->p_name),
- -1,
- SURF_NETWORK_ELEMENT_AS,
- current_routing);
+ simgrid::surf::NetCard *info = new simgrid::surf::NetCardImpl(new_as->p_name, SURF_NETWORK_ELEMENT_AS, current_routing);
if (current_routing == NULL && routing_platf->p_root == NULL) {
/* it is the first one */
struct XBT_PRIVATE NetCardImpl : public NetCard {
public:
- NetCardImpl(char *name, int id, e_surf_network_element_type_t rcType, As *rcComponent)
- : p_rcComponent(rcComponent), p_rcType(rcType), m_id(id), p_name(name) {}
+ NetCardImpl(const char *name, e_surf_network_element_type_t rcType, As *rcComponent)
+ : p_rcComponent(rcComponent),
+ p_rcType(rcType),
+ p_name(xbt_strdup(name)) {}
~NetCardImpl() { xbt_free(p_name);};
int getId() {return m_id;}
private:
As *p_rcComponent;
e_surf_network_element_type_t p_rcType;
- int m_id;
+ int m_id = -1;
char *p_name;
};