From 62eae99ed29ddba069068944f823332b9ca30c4e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 15 Jan 2019 15:32:59 +0200 Subject: libcamera: camera_manager: Turn enumerator into a unique_ptr<> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Niklas Söderlund --- src/libcamera/device_enumerator.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/libcamera/device_enumerator.cpp') 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::create() { - DeviceEnumerator *enumerator; + std::unique_ptr enumerator; /** * \todo Add compile time checks to only try udev enumerator if libudev * is available. */ - enumerator = new DeviceEnumeratorUdev(); + enumerator = utils::make_unique(); if (!enumerator->init()) return enumerator; - delete enumerator; - /* * Either udev is not available or udev initialization failed. Fall back * on the sysfs enumerator. -- cgit v1.2.1