X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/cdab1fefaf41fe170f2382758e507aa2e34521e0..f67dd7cce4ccc1f6c3cb81de389cdc755ba451a4:/src/plugins/file_system/s4u_FileSystem.cpp?ds=sidebyside diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 46b3e48020..7308985348 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -463,15 +463,14 @@ int File::remote_copy(sg_host_t host, const std::string& fullpath) } /* Create file on remote host, write it and close it */ - auto* fd = new File(fullpath, dst_host, nullptr); + File fd(fullpath, dst_host, nullptr); if (local_storage_) { - sg_size_t write_size = fd->local_storage_->write(read_size); - fd->local_storage_->extension()->incr_used_size(write_size); - (*(fd->local_storage_->extension()->get_content()))[path_] = size_; + sg_size_t write_size = fd.local_storage_->write(read_size); + fd.local_storage_->extension()->incr_used_size(write_size); + (*(fd.local_storage_->extension()->get_content()))[path_] = size_; } if (local_disk_) - fd->write(read_size); - delete fd; + fd.write(read_size); return 0; } @@ -512,7 +511,7 @@ std::map* FileSystemDiskExt::parse_content(const std::st auto* parse_content = new std::map(); - std::ifstream* fs = surf_ifsopen(filename); + auto fs = std::unique_ptr(surf_ifsopen(filename)); xbt_assert(not fs->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(), (boost::join(surf_path, ":")).c_str()); @@ -530,7 +529,6 @@ std::map* FileSystemDiskExt::parse_content(const std::st parse_content->insert({tokens.front(), size}); } } while (not fs->eof()); - delete fs; return parse_content; } @@ -541,7 +539,7 @@ std::map* FileSystemStorageExt::parse_content(const std: auto* parse_content = new std::map(); - std::ifstream* fs = surf_ifsopen(filename); + auto fs = std::unique_ptr(surf_ifsopen(filename)); xbt_assert(not fs->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(), (boost::join(surf_path, ":")).c_str()); @@ -559,7 +557,6 @@ std::map* FileSystemStorageExt::parse_content(const std: parse_content->insert({tokens.front(), size}); } } while (not fs->eof()); - delete fs; return parse_content; } @@ -614,7 +611,7 @@ static void on_platform_created() simgrid::s4u::Host* remote_host = simgrid::s4u::Host::by_name_or_null(tokens[2]); xbt_assert(remote_host, "You're trying to access a host that does not exist. Please check your platform file"); - simgrid::s4u::Disk* disk = nullptr; + const simgrid::s4u::Disk* disk = nullptr; for (auto const& d : remote_host->get_disks()) if (d->get_name() == tokens[1]) { disk = d;