mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 23:09:45 +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
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ private:
|
||||||
|
|
||||||
bool isSignatureValid(IPAModule *ipa) const;
|
bool isSignatureValid(IPAModule *ipa) const;
|
||||||
|
|
||||||
std::vector<IPAModule *> modules_;
|
std::vector<std::unique_ptr<IPAModule>> modules_;
|
||||||
|
|
||||||
#if HAVE_IPA_PUBKEY
|
#if HAVE_IPA_PUBKEY
|
||||||
static const uint8_t publicKeyData_[];
|
static const uint8_t publicKeyData_[];
|
||||||
|
|
|
@ -149,11 +149,7 @@ IPAManager::IPAManager()
|
||||||
<< "No IPA found in '" IPA_MODULE_DIR "'";
|
<< "No IPA found in '" IPA_MODULE_DIR "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAManager::~IPAManager()
|
IPAManager::~IPAManager() = default;
|
||||||
{
|
|
||||||
for (IPAModule *module : modules_)
|
|
||||||
delete module;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Identify shared library objects within a directory
|
* \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;
|
unsigned int count = 0;
|
||||||
for (const std::string &file : files) {
|
for (const std::string &file : files) {
|
||||||
IPAModule *ipaModule = new IPAModule(file);
|
auto ipaModule = std::make_unique<IPAModule>(file);
|
||||||
if (!ipaModule->isValid()) {
|
if (!ipaModule->isValid())
|
||||||
delete ipaModule;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
LOG(IPAManager, Debug) << "Loaded IPA module '" << file << "'";
|
LOG(IPAManager, Debug) << "Loaded IPA module '" << file << "'";
|
||||||
|
|
||||||
modules_.push_back(ipaModule);
|
modules_.push_back(std::move(ipaModule));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,9 +244,9 @@ unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth)
|
||||||
IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion,
|
IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion,
|
||||||
uint32_t maxVersion)
|
uint32_t maxVersion)
|
||||||
{
|
{
|
||||||
for (IPAModule *module : modules_) {
|
for (const auto &module : modules_) {
|
||||||
if (module->match(pipe, minVersion, maxVersion))
|
if (module->match(pipe, minVersion, maxVersion))
|
||||||
return module;
|
return module.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue