summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/rkisp1
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-08 03:40:25 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-09 11:26:25 +0200
commite638ffde530440ec3515f40aa75a414ea1100231 (patch)
treebb6b060908cd8b150d35ca59e643be4269f9f2e3 /src/libcamera/pipeline/rkisp1
parentff2ee0174ca62ab4460adfe20049ed05f52615c5 (diff)
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>
Diffstat (limited to 'src/libcamera/pipeline/rkisp1')
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1.cpp13
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1_path.cpp7
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1_path.h3
3 files changed, 5 insertions, 18 deletions
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<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
*/
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
index e05d9dd6..25f482eb 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
@@ -24,15 +24,10 @@ RkISP1Path::RkISP1Path(const char *name, const Span<const PixelFormat> &formats,
const Size &minResolution, const Size &maxResolution)
: name_(name), running_(false), formats_(formats),
minResolution_(minResolution), maxResolution_(maxResolution),
- video_(nullptr), link_(nullptr)
+ link_(nullptr)
{
}
-RkISP1Path::~RkISP1Path()
-{
- delete video_;
-}
-
bool RkISP1Path::init(MediaDevice *media)
{
std::string resizer = std::string("rkisp1_resizer_") + name_ + "path";
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h
index f06ac5a7..3b3e37d2 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h
+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h
@@ -31,7 +31,6 @@ class RkISP1Path
public:
RkISP1Path(const char *name, const Span<const PixelFormat> &formats,
const Size &minResolution, const Size &maxResolution);
- ~RkISP1Path();
bool init(MediaDevice *media);
@@ -67,7 +66,7 @@ private:
const Size maxResolution_;
std::unique_ptr<V4L2Subdevice> resizer_;
- V4L2VideoDevice *video_;
+ std::unique_ptr<V4L2VideoDevice> video_;
MediaLink *link_;
};