summaryrefslogtreecommitdiff
path: root/src/libcamera/device_enumerator.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-15 15:32:59 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-16 18:23:43 +0200
commit62eae99ed29ddba069068944f823332b9ca30c4e (patch)
tree6256732231d6fe1cd7fa693484b089a25e3623c0 /src/libcamera/device_enumerator.cpp
parenta2f095947f847cb7d3f058a74514109928b1df9f (diff)
libcamera: camera_manager: Turn enumerator into a unique_ptr<>
Convey the fact that the CameraManager class owns the DeviceEnumerator instance it creates by using std::unique_ptr<> to store the pointer. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/device_enumerator.cpp')
-rw-r--r--src/libcamera/device_enumerator.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp
index 18d7e868..55c510e3 100644
--- a/src/libcamera/device_enumerator.cpp
+++ b/src/libcamera/device_enumerator.cpp
@@ -14,6 +14,7 @@
#include "device_enumerator.h"
#include "log.h"
#include "media_device.h"
+#include "utils.h"
/**
* \file device_enumerator.h
@@ -128,20 +129,18 @@ bool DeviceMatch::match(const MediaDevice *device) const
* \return A pointer to the newly created device enumerator on success, or
* nullptr if an error occurs
*/
-DeviceEnumerator *DeviceEnumerator::create()
+std::unique_ptr<DeviceEnumerator> DeviceEnumerator::create()
{
- DeviceEnumerator *enumerator;
+ std::unique_ptr<DeviceEnumerator> enumerator;
/**
* \todo Add compile time checks to only try udev enumerator if libudev
* is available.
*/
- enumerator = new DeviceEnumeratorUdev();
+ enumerator = utils::make_unique<DeviceEnumeratorUdev>();
if (!enumerator->init())
return enumerator;
- delete enumerator;
-
/*
* Either udev is not available or udev initialization failed. Fall back
* on the sysfs enumerator.