libcamera: v4l2_device: Return a unique pointer from fromEntityName()

The fromEntityName() function returns a pointer to a newly allocated
V4L2Device instance, which must be deleted by the caller. This opens the
door to memory leaks. Return a unique pointer instead, which conveys the
API semantics better than a sentence in the documentation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Laurent Pinchart
2020-12-08 03:40:25 +02:00
parent ff2ee0174c
commit e638ffde53
9 changed files with 18 additions and 36 deletions
+3 -10
View File
@@ -178,7 +178,6 @@ class PipelineHandlerRkISP1 : public PipelineHandler
{
public:
PipelineHandlerRkISP1(CameraManager *manager);
~PipelineHandlerRkISP1();
CameraConfiguration *generateConfiguration(Camera *camera,
const StreamRoles &roles) override;
@@ -218,8 +217,8 @@ private:
MediaDevice *media_;
std::unique_ptr<V4L2Subdevice> isp_;
V4L2VideoDevice *param_;
V4L2VideoDevice *stat_;
std::unique_ptr<V4L2VideoDevice> param_;
std::unique_ptr<V4L2VideoDevice> stat_;
RkISP1MainPath mainPath_;
RkISP1SelfPath selfPath_;
@@ -599,16 +598,10 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()
}
PipelineHandlerRkISP1::PipelineHandlerRkISP1(CameraManager *manager)
: PipelineHandler(manager), param_(nullptr), stat_(nullptr)
: PipelineHandler(manager)
{
}
PipelineHandlerRkISP1::~PipelineHandlerRkISP1()
{
delete param_;
delete stat_;
}
/* -----------------------------------------------------------------------------
* Pipeline Operations
*/