From: Arnaud Giersch Date: Thu, 18 Apr 2019 12:51:02 +0000 (+0200) Subject: Remove custom destructors for s4u_Filesystem. X-Git-Tag: v3.22.2~95 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ec53f56800087e5f383314bf6955ffab3a0e5c35 Remove custom destructors for s4u_Filesystem. --- diff --git a/include/simgrid/plugins/file_system.h b/include/simgrid/plugins/file_system.h index 56617193ce..4d6190dd06 100644 --- a/include/simgrid/plugins/file_system.h +++ b/include/simgrid/plugins/file_system.h @@ -73,6 +73,7 @@ SG_END_DECL() #include #include +#include #include namespace simgrid { @@ -139,16 +140,15 @@ public: explicit FileSystemStorageExt(Storage* ptr); FileSystemStorageExt(const FileSystemStorageExt&) = delete; FileSystemStorageExt& operator=(const FileSystemStorageExt&) = delete; - ~FileSystemStorageExt(); std::map* parse_content(const std::string& filename); - std::map* get_content() { return content_; } + std::map* get_content() { return content_.get(); } sg_size_t get_size() { return size_; } sg_size_t get_used_size() { return used_size_; } void decr_used_size(sg_size_t size) { used_size_ -= size; } void incr_used_size(sg_size_t size) { used_size_ += size; } private: - std::map* content_; + std::unique_ptr> content_; sg_size_t used_size_ = 0; sg_size_t size_ = 0; }; @@ -159,8 +159,7 @@ public: FileDescriptorHostExt() = default; FileDescriptorHostExt(const FileDescriptorHostExt&) = delete; FileDescriptorHostExt& operator=(const FileDescriptorHostExt&) = delete; - ~FileDescriptorHostExt() { delete file_descriptor_table; } - std::vector* file_descriptor_table = nullptr; // Created lazily on need + std::unique_ptr> file_descriptor_table = nullptr; // Created lazily on need }; } // namespace s4u } // namespace simgrid diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 6eb42eed54..f570a6dcbd 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -53,7 +53,7 @@ File::File(const std::string& fullpath, sg_host_t host, void* userdata) : fullpa // assign a file descriptor id to the newly opened File FileDescriptorHostExt* ext = host->extension(); if (ext->file_descriptor_table == nullptr) { - ext->file_descriptor_table = new std::vector(sg_storage_max_file_descriptors); + ext->file_descriptor_table.reset(new std::vector(sg_storage_max_file_descriptors)); std::iota(ext->file_descriptor_table->rbegin(), ext->file_descriptor_table->rend(), 0); // Fill with ..., 1, 0. } xbt_assert(not ext->file_descriptor_table->empty(), "Too much files are opened! Some have to be closed."); @@ -288,15 +288,10 @@ int File::remote_move(sg_host_t host, const char* fullpath) FileSystemStorageExt::FileSystemStorageExt(simgrid::s4u::Storage* ptr) { - content_ = parse_content(ptr->get_impl()->content_name); + content_.reset(parse_content(ptr->get_impl()->content_name)); size_ = ptr->get_impl()->size_; } -FileSystemStorageExt::~FileSystemStorageExt() -{ - delete content_; -} - std::map* FileSystemStorageExt::parse_content(const std::string& filename) { if (filename.empty())