Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move all netcards into the dict, and the dict to the engine
[simgrid.git] / src / s4u / s4u_host.cpp
index 6ae075f..1499c26 100644 (file)
@@ -43,7 +43,7 @@ simgrid::xbt::signal<void(Host&)> Host::onStateChange;
 Host::Host(const char* name)
   : name_(name)
 {
-  xbt_assert(sg_host_by_name(name) == nullptr, "Refusing to create a second host named '%s'.", name);
+  xbt_assert(Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name);
   host_list[name_] = this;
 }
 
@@ -52,8 +52,9 @@ Host::~Host()
   xbt_assert(currentlyDestroying_, "Please call h->destroy() instead of manually deleting it.");
 
   delete pimpl_;
+  if (pimpl_netcard != nullptr) // not removed yet by a children class
+    xbt_dict_remove(netcards_dict, name_.c_str());
   delete pimpl_cpu;
-  delete pimpl_netcard;
   delete mounts;
 }