Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
plug leak
[simgrid.git] / src / surf / HostImpl.cpp
index 5366a5d..a692a03 100644 (file)
@@ -107,7 +107,11 @@ HostImpl::HostImpl(s4u::Host* host) : piface_(host)
 }
 
 /** @brief use destroy() instead of this destructor */
-HostImpl::~HostImpl() = default;
+HostImpl::~HostImpl()
+{
+  for (auto mnt : storage_)
+    xbt_free(mnt.name);
+}
 
 simgrid::surf::Storage* HostImpl::findStorageOnMountList(const char* mount)
 {
@@ -138,23 +142,21 @@ xbt_dict_t HostImpl::getMountedStorageList()
   return storage_list;
 }
 
-std::vector<const char*> HostImpl::getAttachedStorageList()
+void HostImpl::getAttachedStorageList(std::vector<const char*>* storages)
 {
   xbt_lib_cursor_t cursor;
   char* key;
   void** data;
-  std::vector<const char*> result;
   xbt_lib_foreach(storage_lib, cursor, key, data)
   {
     if (xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != nullptr) {
       simgrid::surf::Storage* storage = static_cast<simgrid::surf::Storage*>(
           xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
       if (!strcmp(static_cast<const char*>(storage->attach_), piface_->cname())) {
-        result.push_back(storage->cname());
+        storages->push_back(storage->cname());
       }
     }
   }
-  return result;
 }
 
 Action* HostImpl::open(const char* fullpath)