aboutsummaryrefslogtreecommitdiff
path: root/src/core/file_sys/sdmc_factory.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-10-16 09:05:47 -0400
committerLioncash <mathew1800@gmail.com>2018-10-16 09:38:52 -0400
commit92495f4f708b0b5ea863736e83259fa9468086b7 (patch)
treeb36ca87fcca87afb202c637bc2e5ee2ca6d9d823 /src/core/file_sys/sdmc_factory.cpp
parent2850c1f53cd272ff3efb8fcd89e2d0c8fa497568 (diff)
file_sys/registered_cache: Use unique_ptr and regular pointers instead of shared_ptrs where applicable
The data retrieved in these cases are ultimately chiefly owned by either the RegisteredCache instance itself, or the filesystem factories. Both these should live throughout the use of their contained data. If they don't, it should be considered an interface/design issue, and using shared_ptr instances here would mask that, as the data would always be prolonged after the main owner's lifetime ended. This makes the lifetime of the data explicit and makes it harder to accidentally create cyclic references. It also makes the interface slightly more flexible than the previous API, as a shared_ptr can be created from a unique_ptr, but not the other way around, so this allows for that use-case if it ever becomes necessary in some form.
Diffstat (limited to 'src/core/file_sys/sdmc_factory.cpp')
-rw-r--r--src/core/file_sys/sdmc_factory.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp
index d66a9c9a42..bd3a570588 100644
--- a/src/core/file_sys/sdmc_factory.cpp
+++ b/src/core/file_sys/sdmc_factory.cpp
@@ -10,10 +10,10 @@
namespace FileSys {
SDMCFactory::SDMCFactory(VirtualDir dir_)
- : dir(std::move(dir_)), contents(std::make_shared<RegisteredCache>(
+ : dir(std::move(dir_)), contents(std::make_unique<RegisteredCache>(
GetOrCreateDirectoryRelative(dir, "/Nintendo/Contents/registered"),
[](const VirtualFile& file, const NcaID& id) {
- return std::make_shared<NAX>(file, id)->GetDecrypted();
+ return NAX{file, id}.GetDecrypted();
})) {}
SDMCFactory::~SDMCFactory() = default;
@@ -22,8 +22,8 @@ ResultVal<VirtualDir> SDMCFactory::Open() {
return MakeResult<VirtualDir>(dir);
}
-std::shared_ptr<RegisteredCache> SDMCFactory::GetSDMCContents() const {
- return contents;
+RegisteredCache* SDMCFactory::GetSDMCContents() const {
+ return contents.get();
}
} // namespace FileSys