Show a patch.

GET /api/patches/25723/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 25723,
    "url": "https://patchwork.libcamera.org/api/patches/25723/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/25723/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20260113000808.15395-4-laurent.pinchart@ideasonboard.com>",
    "date": "2026-01-13T00:07:35",
    "name": "[03/36] libcamera: Replace plain pointers with std::unique<>",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "dfccbb90e16fe91409bc7f047d45ba7d236d0bd7",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/25723/mbox/",
    "series": [
        {
            "id": 5703,
            "url": "https://patchwork.libcamera.org/api/series/5703/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5703",
            "date": "2026-01-13T00:07:32",
            "name": "libcamera: Global configuration file improvements",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5703/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/25723/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/25723/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 81BD6C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Jan 2026 00:08:38 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2B22361FC3;\n\tTue, 13 Jan 2026 01:08:38 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61A3761FBC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 01:08:34 +0100 (CET)",
            "from pendragon.ideasonboard.com (81-175-209-152.bb.dnainternet.fi\n\t[81.175.209.152])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 9E7FA66B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Jan 2026 01:08:08 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"p4jvYH72\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768262888;\n\tbh=WsJIqEiDLuJVipvG1aa37QPP5JBilyn21MSnGgTO8eQ=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=p4jvYH722qwqt+L7ratN/aV+JyI+Zeho4q6nFxLmGXVrGRmtaMq8466uQoPG3vzEa\n\tx+OrjXtQHVB8IDk8l0oNi9oNjkJoDyuuw+PkWWwYWJAEhzVD006o0GiL/QQ8P+4leW\n\tjgqj0tESf8yIa+ENtpJm+vJC2mdTPOe3IGiWDQMc=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH 03/36] libcamera: Replace plain pointers with std::unique<>",
        "Date": "Tue, 13 Jan 2026 02:07:35 +0200",
        "Message-ID": "<20260113000808.15395-4-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.51.2",
        "In-Reply-To": "<20260113000808.15395-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20260113000808.15395-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "libcamera uses std::unique_ptr<> to simplify life time management of\nobjects and avoid leaks. For historical reasons there are a fair number\nof plain pointers with manual memory management. Replace them with\nstd::unique_ptr<> when the conversion is simple.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n .../guides/application-developer.rst          |  5 +++--\n Documentation/guides/pipeline-handler.rst     |  7 +++---\n .../internal/device_enumerator_udev.h         |  2 +-\n include/libcamera/internal/ipc_unixsocket.h   |  3 ++-\n include/libcamera/internal/v4l2_device.h      |  2 +-\n include/libcamera/internal/v4l2_videodevice.h | 12 +++++-----\n src/apps/qcam/main.cpp                        |  5 ++---\n src/apps/qcam/main_window.cpp                 | 11 +++++-----\n src/apps/qcam/main_window.h                   |  2 +-\n src/libcamera/device_enumerator_udev.cpp      |  6 ++---\n src/libcamera/ipc_unixsocket.cpp              |  7 +++---\n src/libcamera/v4l2_device.cpp                 |  5 +++--\n src/libcamera/v4l2_videodevice.cpp            | 22 ++++++++-----------\n src/v4l2/v4l2_camera.cpp                      |  7 +++---\n src/v4l2/v4l2_camera.h                        |  2 +-\n src/v4l2/v4l2_compat_manager.cpp              | 18 +++++----------\n src/v4l2/v4l2_compat_manager.h                |  2 +-\n 17 files changed, 52 insertions(+), 66 deletions(-)",
    "diff": "diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst\nindex 06c07d1e9449..d981b6a4f9e7 100644\n--- a/Documentation/guides/application-developer.rst\n+++ b/Documentation/guides/application-developer.rst\n@@ -279,7 +279,8 @@ as the parameter of the ``FrameBufferAllocator::buffers()`` function.\n \n .. code:: cpp\n \n-   FrameBufferAllocator *allocator = new FrameBufferAllocator(camera);\n+   std::unique_ptr<FrameBufferAllocator> allocator =\n+       std::make_unique<FrameBufferAllocator>(camera);\n \n    for (StreamConfiguration &cfg : *config) {\n        int ret = allocator->allocate(cfg.stream());\n@@ -539,7 +540,7 @@ uses, so needs to do the following:\n \n    camera->stop();\n    allocator->free(stream);\n-   delete allocator;\n+   allocator.reset();\n    camera->release();\n    camera.reset();\n    cm->stop();\ndiff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst\nindex 85d9cc870021..c28eccb7cf0e 100644\n--- a/Documentation/guides/pipeline-handler.rst\n+++ b/Documentation/guides/pipeline-handler.rst\n@@ -424,20 +424,19 @@ it will be used:\n    {\n    public:\n           VividCameraData(PipelineHandler *pipe, MediaDevice *media)\n-                : Camera::Private(pipe), media_(media), video_(nullptr)\n+                : Camera::Private(pipe), media_(media)\n           {\n           }\n \n           ~VividCameraData()\n           {\n-                delete video_;\n           }\n \n           int init();\n           void bufferReady(FrameBuffer *buffer);\n \n           MediaDevice *media_;\n-          V4L2VideoDevice *video_;\n+          std::unique_ptr<V4L2VideoDevice> video_;\n           Stream stream_;\n    };\n \n@@ -468,7 +467,7 @@ open a single capture device named 'vivid-000-vid-cap' by the device.\n \n    int VividCameraData::init()\n    {\n-          video_ = new V4L2VideoDevice(media_->getEntityByName(\"vivid-000-vid-cap\"));\n+          video_ = std::make_unique<V4L2VideoDevice>(media_->getEntityByName(\"vivid-000-vid-cap\"));\n           if (video_->open())\n                 return -ENODEV;\n \ndiff --git a/include/libcamera/internal/device_enumerator_udev.h b/include/libcamera/internal/device_enumerator_udev.h\nindex 0bf78b551e75..1ce988ab84d1 100644\n--- a/include/libcamera/internal/device_enumerator_udev.h\n+++ b/include/libcamera/internal/device_enumerator_udev.h\n@@ -69,7 +69,7 @@ private:\n \n \tstruct udev *udev_;\n \tstruct udev_monitor *monitor_;\n-\tEventNotifier *notifier_;\n+\tstd::unique_ptr<EventNotifier> notifier_;\n \n \tstd::set<dev_t> orphans_;\n \tstd::unordered_set<dev_t> devices_;\ndiff --git a/include/libcamera/internal/ipc_unixsocket.h b/include/libcamera/internal/ipc_unixsocket.h\nindex 48bb7a9422b5..57614fa3f0c7 100644\n--- a/include/libcamera/internal/ipc_unixsocket.h\n+++ b/include/libcamera/internal/ipc_unixsocket.h\n@@ -7,6 +7,7 @@\n \n #pragma once\n \n+#include <memory>\n #include <stdint.h>\n #include <sys/types.h>\n #include <vector>\n@@ -53,7 +54,7 @@ private:\n \tUniqueFD fd_;\n \tbool headerReceived_;\n \tstruct Header header_;\n-\tEventNotifier *notifier_;\n+\tstd::unique_ptr<EventNotifier> notifier_;\n };\n \n } /* namespace libcamera */\ndiff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h\nindex dbbd118abd00..8c4c59bf7773 100644\n--- a/include/libcamera/internal/v4l2_device.h\n+++ b/include/libcamera/internal/v4l2_device.h\n@@ -89,7 +89,7 @@ private:\n \tstd::string deviceNode_;\n \tUniqueFD fd_;\n \n-\tEventNotifier *fdEventNotifier_;\n+\tstd::unique_ptr<EventNotifier> fdEventNotifier_;\n \tbool frameStartEnabled_;\n };\n \ndiff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 57db0036db6b..10367e4e178a 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -280,10 +280,10 @@ private:\n \tenum v4l2_buf_type bufferType_;\n \tenum v4l2_memory memoryType_;\n \n-\tV4L2BufferCache *cache_;\n+\tstd::unique_ptr<V4L2BufferCache> cache_;\n \tstd::map<unsigned int, FrameBuffer *> queuedBuffers_;\n \n-\tEventNotifier *fdBufferNotifier_;\n+\tstd::unique_ptr<EventNotifier> fdBufferNotifier_;\n \n \tState state_;\n \tstd::optional<unsigned int> firstFrame_;\n@@ -301,14 +301,14 @@ public:\n \tint open();\n \tvoid close();\n \n-\tV4L2VideoDevice *output() { return output_; }\n-\tV4L2VideoDevice *capture() { return capture_; }\n+\tV4L2VideoDevice *output() { return output_.get(); }\n+\tV4L2VideoDevice *capture() { return capture_.get(); }\n \n private:\n \tstd::string deviceNode_;\n \n-\tV4L2VideoDevice *output_;\n-\tV4L2VideoDevice *capture_;\n+\tstd::unique_ptr<V4L2VideoDevice> output_;\n+\tstd::unique_ptr<V4L2VideoDevice> capture_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/apps/qcam/main.cpp b/src/apps/qcam/main.cpp\nindex d0bde14130fb..8c43d43f0dca 100644\n--- a/src/apps/qcam/main.cpp\n+++ b/src/apps/qcam/main.cpp\n@@ -73,7 +73,7 @@ int main(int argc, char **argv)\n \tsa.sa_handler = &signalHandler;\n \tsigaction(SIGINT, &sa, nullptr);\n \n-\tCameraManager *cm = new libcamera::CameraManager();\n+\tstd::unique_ptr<CameraManager> cm = std::make_unique<CameraManager>();\n \n \tret = cm->start();\n \tif (ret) {\n@@ -82,13 +82,12 @@ int main(int argc, char **argv)\n \t\treturn EXIT_FAILURE;\n \t}\n \n-\tMainWindow *mainWindow = new MainWindow(cm, options);\n+\tMainWindow *mainWindow = new MainWindow(cm.get(), options);\n \tmainWindow->show();\n \tret = app.exec();\n \tdelete mainWindow;\n \n \tcm->stop();\n-\tdelete cm;\n \n \treturn ret;\n }\ndiff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp\nindex 96a2d50901b7..e84e19d70728 100644\n--- a/src/apps/qcam/main_window.cpp\n+++ b/src/apps/qcam/main_window.cpp\n@@ -86,8 +86,8 @@ private:\n };\n \n MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n-\t: saveRaw_(nullptr), options_(options), cm_(cm), allocator_(nullptr),\n-\t  isCapturing_(false), captureRaw_(false)\n+\t: saveRaw_(nullptr), options_(options), cm_(cm), isCapturing_(false),\n+\t  captureRaw_(false)\n {\n \tint ret;\n \n@@ -449,7 +449,7 @@ int MainWindow::startCapture()\n \t\tsaveRaw_->setEnabled(config_->size() == 2);\n \n \t/* Allocate and map buffers. */\n-\tallocator_ = new FrameBufferAllocator(camera_);\n+\tallocator_ = std::make_unique<FrameBufferAllocator>(camera_);\n \tfor (StreamConfiguration &config : *config_) {\n \t\tStream *stream = config.stream();\n \n@@ -530,8 +530,7 @@ error:\n \n \tfreeBuffers_.clear();\n \n-\tdelete allocator_;\n-\tallocator_ = nullptr;\n+\tallocator_.reset();\n \n \treturn ret;\n }\n@@ -563,7 +562,7 @@ void MainWindow::stopCapture()\n \trequests_.clear();\n \tfreeQueue_.clear();\n \n-\tdelete allocator_;\n+\tallocator_.reset();\n \n \tisCapturing_ = false;\n \ndiff --git a/src/apps/qcam/main_window.h b/src/apps/qcam/main_window.h\nindex 81fcf915ade5..20d369ad2318 100644\n--- a/src/apps/qcam/main_window.h\n+++ b/src/apps/qcam/main_window.h\n@@ -109,7 +109,7 @@ private:\n \t/* Camera manager, camera, configuration and buffers */\n \tlibcamera::CameraManager *cm_;\n \tstd::shared_ptr<libcamera::Camera> camera_;\n-\tlibcamera::FrameBufferAllocator *allocator_;\n+\tstd::unique_ptr<libcamera::FrameBufferAllocator> allocator_;\n \n \tstd::unique_ptr<libcamera::CameraConfiguration> config_;\n \tstd::map<libcamera::FrameBuffer *, std::unique_ptr<Image>> mappedBuffers_;\ndiff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\nindex 3195dd06e2fc..8b9376ca6ac4 100644\n--- a/src/libcamera/device_enumerator_udev.cpp\n+++ b/src/libcamera/device_enumerator_udev.cpp\n@@ -28,14 +28,12 @@ namespace libcamera {\n LOG_DECLARE_CATEGORY(DeviceEnumerator)\n \n DeviceEnumeratorUdev::DeviceEnumeratorUdev()\n-\t: udev_(nullptr), monitor_(nullptr), notifier_(nullptr)\n+\t: udev_(nullptr), monitor_(nullptr)\n {\n }\n \n DeviceEnumeratorUdev::~DeviceEnumeratorUdev()\n {\n-\tdelete notifier_;\n-\n \tif (monitor_)\n \t\tudev_monitor_unref(monitor_);\n \tif (udev_)\n@@ -212,7 +210,7 @@ done:\n \t\treturn ret;\n \n \tint fd = udev_monitor_get_fd(monitor_);\n-\tnotifier_ = new EventNotifier(fd, EventNotifier::Read);\n+\tnotifier_ = std::make_unique<EventNotifier>(fd, EventNotifier::Read);\n \tnotifier_->activated.connect(this, &DeviceEnumeratorUdev::udevNotify);\n \n \treturn 0;\ndiff --git a/src/libcamera/ipc_unixsocket.cpp b/src/libcamera/ipc_unixsocket.cpp\nindex 002053e35557..6ec5a5cb6595 100644\n--- a/src/libcamera/ipc_unixsocket.cpp\n+++ b/src/libcamera/ipc_unixsocket.cpp\n@@ -70,7 +70,7 @@ LOG_DEFINE_CATEGORY(IPCUnixSocket)\n  */\n \n IPCUnixSocket::IPCUnixSocket()\n-\t: headerReceived_(false), notifier_(nullptr)\n+\t: headerReceived_(false)\n {\n }\n \n@@ -130,7 +130,7 @@ int IPCUnixSocket::bind(UniqueFD fd)\n \t\treturn -EINVAL;\n \n \tfd_ = std::move(fd);\n-\tnotifier_ = new EventNotifier(fd_.get(), EventNotifier::Read);\n+\tnotifier_ = std::make_unique<EventNotifier>(fd_.get(), EventNotifier::Read);\n \tnotifier_->activated.connect(this, &IPCUnixSocket::dataNotifier);\n \n \treturn 0;\n@@ -146,8 +146,7 @@ void IPCUnixSocket::close()\n \tif (!isBound())\n \t\treturn;\n \n-\tdelete notifier_;\n-\tnotifier_ = nullptr;\n+\tnotifier_.reset();\n \n \tfd_.reset();\n \theaderReceived_ = false;\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 1582c03efacd..206efb0d951d 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -123,7 +123,8 @@ int V4L2Device::setFd(UniqueFD fd)\n \n \tfd_ = std::move(fd);\n \n-\tfdEventNotifier_ = new EventNotifier(fd_.get(), EventNotifier::Exception);\n+\tfdEventNotifier_ = std::make_unique<EventNotifier>(fd_.get(),\n+\t\t\t\t\t\t\t   EventNotifier::Exception);\n \tfdEventNotifier_->activated.connect(this, &V4L2Device::eventAvailable);\n \tfdEventNotifier_->setEnabled(false);\n \n@@ -142,7 +143,7 @@ void V4L2Device::close()\n \tif (!isOpen())\n \t\treturn;\n \n-\tdelete fdEventNotifier_;\n+\tfdEventNotifier_.reset();\n \n \tfd_.reset();\n }\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 25b61d049a0e..ddb757b04e59 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -535,8 +535,7 @@ std::ostream &operator<<(std::ostream &out, const V4L2DeviceFormat &f)\n  */\n V4L2VideoDevice::V4L2VideoDevice(const std::string &deviceNode)\n \t: V4L2Device(deviceNode), formatInfo_(nullptr), cache_(nullptr),\n-\t  fdBufferNotifier_(nullptr), state_(State::Stopped),\n-\t  watchdogDuration_(0.0)\n+\t  state_(State::Stopped), watchdogDuration_(0.0)\n {\n \t/*\n \t * We default to an MMAP based CAPTURE video device, however this will\n@@ -626,7 +625,7 @@ int V4L2VideoDevice::open()\n \t\treturn -EINVAL;\n \t}\n \n-\tfdBufferNotifier_ = new EventNotifier(fd(), notifierType);\n+\tfdBufferNotifier_ = std::make_unique<EventNotifier>(fd(), notifierType);\n \tfdBufferNotifier_->activated.connect(this, &V4L2VideoDevice::bufferAvailable);\n \tfdBufferNotifier_->setEnabled(false);\n \n@@ -715,7 +714,7 @@ int V4L2VideoDevice::open(SharedFD handle, enum v4l2_buf_type type)\n \t\treturn -EINVAL;\n \t}\n \n-\tfdBufferNotifier_ = new EventNotifier(fd(), notifierType);\n+\tfdBufferNotifier_ = std::make_unique<EventNotifier>(fd(), notifierType);\n \tfdBufferNotifier_->activated.connect(this, &V4L2VideoDevice::bufferAvailable);\n \tfdBufferNotifier_->setEnabled(false);\n \n@@ -760,7 +759,7 @@ void V4L2VideoDevice::close()\n \t\treturn;\n \n \treleaseBuffers();\n-\tdelete fdBufferNotifier_;\n+\tfdBufferNotifier_.reset();\n \n \tformatInfo_ = nullptr;\n \n@@ -1374,7 +1373,7 @@ int V4L2VideoDevice::allocateBuffers(unsigned int count,\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tcache_ = new V4L2BufferCache(*buffers);\n+\tcache_ = std::make_unique<V4L2BufferCache>(*buffers);\n \tmemoryType_ = V4L2_MEMORY_MMAP;\n \n \treturn ret;\n@@ -1599,7 +1598,7 @@ int V4L2VideoDevice::importBuffers(unsigned int count)\n \tif (ret)\n \t\treturn ret;\n \n-\tcache_ = new V4L2BufferCache(count);\n+\tcache_ = std::make_unique<V4L2BufferCache>(count);\n \n \tLOG(V4L2, Debug) << \"Prepared to import \" << count << \" buffers\";\n \n@@ -1621,8 +1620,7 @@ int V4L2VideoDevice::releaseBuffers()\n \n \tLOG(V4L2, Debug) << \"Releasing buffers\";\n \n-\tdelete cache_;\n-\tcache_ = nullptr;\n+\tcache_.reset();\n \n \treturn requestBuffers(0, memoryType_);\n }\n@@ -2199,14 +2197,12 @@ V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelForma\n V4L2M2MDevice::V4L2M2MDevice(const std::string &deviceNode)\n \t: deviceNode_(deviceNode)\n {\n-\toutput_ = new V4L2VideoDevice(deviceNode);\n-\tcapture_ = new V4L2VideoDevice(deviceNode);\n+\toutput_ = std::make_unique<V4L2VideoDevice>(deviceNode);\n+\tcapture_ = std::make_unique<V4L2VideoDevice>(deviceNode);\n }\n \n V4L2M2MDevice::~V4L2M2MDevice()\n {\n-\tdelete capture_;\n-\tdelete output_;\n }\n \n /**\ndiff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp\nindex 94d138cd5710..412ab4ea678e 100644\n--- a/src/v4l2/v4l2_camera.cpp\n+++ b/src/v4l2/v4l2_camera.cpp\n@@ -20,7 +20,7 @@ LOG_DECLARE_CATEGORY(V4L2Compat)\n \n V4L2Camera::V4L2Camera(std::shared_ptr<Camera> camera)\n \t: camera_(camera), controls_(controls::controls), isRunning_(false),\n-\t  bufferAllocator_(nullptr), efd_(-1), bufferAvailableCount_(0)\n+\t  efd_(-1), bufferAvailableCount_(0)\n {\n \tcamera_->requestCompleted.connect(this, &V4L2Camera::requestComplete);\n }\n@@ -43,7 +43,7 @@ int V4L2Camera::open(StreamConfiguration *streamConfig)\n \t\treturn -EINVAL;\n \t}\n \n-\tbufferAllocator_ = new FrameBufferAllocator(camera_);\n+\tbufferAllocator_ = std::make_unique<FrameBufferAllocator>(camera_);\n \n \t*streamConfig = config_->at(0);\n \treturn 0;\n@@ -53,8 +53,7 @@ void V4L2Camera::close()\n {\n \trequestPool_.clear();\n \n-\tdelete bufferAllocator_;\n-\tbufferAllocator_ = nullptr;\n+\tbufferAllocator_.reset();\n \n \tcamera_->release();\n }\ndiff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h\nindex 9bd161b909de..3d09ae7d6057 100644\n--- a/src/v4l2/v4l2_camera.h\n+++ b/src/v4l2/v4l2_camera.h\n@@ -80,7 +80,7 @@ private:\n \tbool isRunning_;\n \n \tlibcamera::Mutex bufferLock_;\n-\tlibcamera::FrameBufferAllocator *bufferAllocator_;\n+\tstd::unique_ptr<libcamera::FrameBufferAllocator> bufferAllocator_;\n \n \tstd::vector<std::unique_ptr<libcamera::Request>> requestPool_;\n \ndiff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\nindex f53fb300dde8..a92f2e2944fc 100644\n--- a/src/v4l2/v4l2_compat_manager.cpp\n+++ b/src/v4l2/v4l2_compat_manager.cpp\n@@ -54,25 +54,21 @@ V4L2CompatManager::~V4L2CompatManager()\n {\n \tfiles_.clear();\n \tmmaps_.clear();\n+\tproxies_.clear();\n \n-\tif (cm_) {\n-\t\tproxies_.clear();\n+\tif (cm_)\n \t\tcm_->stop();\n-\t\tdelete cm_;\n-\t\tcm_ = nullptr;\n-\t}\n }\n \n int V4L2CompatManager::start()\n {\n-\tcm_ = new CameraManager();\n+\tcm_ = std::make_unique<CameraManager>();\n \n \tint ret = cm_->start();\n \tif (ret) {\n \t\tLOG(V4L2Compat, Error) << \"Failed to start camera manager: \"\n \t\t\t\t       << strerror(-ret);\n-\t\tdelete cm_;\n-\t\tcm_ = nullptr;\n+\t\tcm_.reset();\n \t\treturn ret;\n \t}\n \n@@ -83,10 +79,8 @@ int V4L2CompatManager::start()\n \t * created here to wrap a camera device.\n \t */\n \tauto cameras = cm_->cameras();\n-\tfor (auto [index, camera] : utils::enumerate(cameras)) {\n-\t\tV4L2CameraProxy *proxy = new V4L2CameraProxy(index, camera);\n-\t\tproxies_.emplace_back(proxy);\n-\t}\n+\tfor (auto [index, camera] : utils::enumerate(cameras))\n+\t\tproxies_.emplace_back(std::make_unique<V4L2CameraProxy>(index, camera));\n \n \treturn 0;\n }\ndiff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h\nindex f7c6f1228282..13673d604a63 100644\n--- a/src/v4l2/v4l2_compat_manager.h\n+++ b/src/v4l2/v4l2_compat_manager.h\n@@ -61,7 +61,7 @@ private:\n \n \tFileOperations fops_;\n \n-\tlibcamera::CameraManager *cm_;\n+\tstd::unique_ptr<libcamera::CameraManager> cm_;\n \n \tstd::vector<std::unique_ptr<V4L2CameraProxy>> proxies_;\n \tstd::map<int, std::shared_ptr<V4L2CameraFile>> files_;\n",
    "prefixes": [
        "03/36"
    ]
}