diff options
author | Barnabás Pőcze <barnabas.pocze@ideasonboard.com> | 2025-01-22 18:17:19 +0100 |
---|---|---|
committer | Barnabás Pőcze <barnabas.pocze@ideasonboard.com> | 2025-03-21 15:43:41 +0100 |
commit | d716200d2b81aa884cf395ec742c6df06675306b (patch) | |
tree | 8df0a02b22e3d4e7e3ef5b2bcefcf1f40d8d84c7 /src | |
parent | 4a5ad4e9b04e0c41efddc9800d4462c23c016904 (diff) |
libcamera: ipa_manager: Store `IPAModule`s in `std::unique_ptr`
Express the ownership more clearly by using a smart pointer type.
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/ipa_manager.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index cfc24d38..830750dc 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -149,11 +149,7 @@ IPAManager::IPAManager() << "No IPA found in '" IPA_MODULE_DIR "'"; } -IPAManager::~IPAManager() -{ - for (IPAModule *module : modules_) - delete module; -} +IPAManager::~IPAManager() = default; /** * \brief Identify shared library objects within a directory @@ -226,15 +222,13 @@ unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth) unsigned int count = 0; for (const std::string &file : files) { - IPAModule *ipaModule = new IPAModule(file); - if (!ipaModule->isValid()) { - delete ipaModule; + auto ipaModule = std::make_unique<IPAModule>(file); + if (!ipaModule->isValid()) continue; - } LOG(IPAManager, Debug) << "Loaded IPA module '" << file << "'"; - modules_.push_back(ipaModule); + modules_.push_back(std::move(ipaModule)); count++; } @@ -250,9 +244,9 @@ unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth) IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion, uint32_t maxVersion) { - for (IPAModule *module : modules_) { + for (const auto &module : modules_) { if (module->match(pipe, minVersion, maxVersion)) - return module; + return module.get(); } return nullptr; |