A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use std::unique_ptr with std::ifstream.
[simgrid.git]
/
src
/
plugins
/
file_system
/
s4u_FileSystem.cpp
diff --git
a/src/plugins/file_system/s4u_FileSystem.cpp
b/src/plugins/file_system/s4u_FileSystem.cpp
index 46b3e480205b9ecea4340da7fd9f96eb9ef28521..73089853485ef35e73be73f671d839282b44cdb7 100644
(file)
--- 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 */
}
/* 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_) {
if (local_storage_) {
- sg_size_t write_size = fd
->
local_storage_->write(read_size);
- fd
->
local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
- (*(fd
->
local_storage_->extension<FileSystemStorageExt>()->get_content()))[path_] = size_;
+ sg_size_t write_size = fd
.
local_storage_->write(read_size);
+ fd
.
local_storage_->extension<FileSystemStorageExt>()->incr_used_size(write_size);
+ (*(fd
.
local_storage_->extension<FileSystemStorageExt>()->get_content()))[path_] = size_;
}
if (local_disk_)
}
if (local_disk_)
- fd->write(read_size);
- delete fd;
+ fd.write(read_size);
return 0;
}
return 0;
}
@@
-512,7
+511,7
@@
std::map<std::string, sg_size_t>* FileSystemDiskExt::parse_content(const std::st
auto* parse_content = new std::map<std::string, sg_size_t>();
auto* parse_content = new std::map<std::string, sg_size_t>();
-
std::ifstream* fs = surf_ifsopen(filename
);
+
auto fs = std::unique_ptr<std::ifstream>(surf_ifsopen(filename)
);
xbt_assert(not fs->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(),
(boost::join(surf_path, ":")).c_str());
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<std::string, sg_size_t>* FileSystemDiskExt::parse_content(const std::st
parse_content->insert({tokens.front(), size});
}
} while (not fs->eof());
parse_content->insert({tokens.front(), size});
}
} while (not fs->eof());
- delete fs;
return parse_content;
}
return parse_content;
}
@@
-541,7
+539,7
@@
std::map<std::string, sg_size_t>* FileSystemStorageExt::parse_content(const std:
auto* parse_content = new std::map<std::string, sg_size_t>();
auto* parse_content = new std::map<std::string, sg_size_t>();
-
std::ifstream* fs = surf_ifsopen(filename
);
+
auto fs = std::unique_ptr<std::ifstream>(surf_ifsopen(filename)
);
xbt_assert(not fs->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(),
(boost::join(surf_path, ":")).c_str());
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<std::string, sg_size_t>* FileSystemStorageExt::parse_content(const std:
parse_content->insert({tokens.front(), size});
}
} while (not fs->eof());
parse_content->insert({tokens.front(), size});
}
} while (not fs->eof());
- delete fs;
return parse_content;
}
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::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;
for (auto const& d : remote_host->get_disks())
if (d->get_name() == tokens[1]) {
disk = d;