mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 14:59:44 +03:00
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>
This commit is contained in:
parent
4a5ad4e9b0
commit
d716200d2b
2 changed files with 8 additions and 13 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
|
@ -67,7 +68,7 @@ private:
|
|||
|
||||
bool isSignatureValid(IPAModule *ipa) const;
|
||||
|
||||
std::vector<IPAModule *> modules_;
|
||||
std::vector<std::unique_ptr<IPAModule>> modules_;
|
||||
|
||||
#if HAVE_IPA_PUBKEY
|
||||
static const uint8_t publicKeyData_[];
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue