From e638ffde530440ec3515f40aa75a414ea1100231 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 8 Dec 2020 03:40:25 +0200 Subject: 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 Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/libcamera/pipeline/rkisp1/rkisp1.cpp') diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index c34a30a9..4d98c902 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -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 isp_; - V4L2VideoDevice *param_; - V4L2VideoDevice *stat_; + std::unique_ptr param_; + std::unique_ptr 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 */ -- cgit v1.2.1