libcamera: Replace plain pointers with std::unique<>
libcamera uses std::unique_ptr<> to simplify life time management of objects and avoid leaks. For historical reasons there are a fair number of plain pointers with manual memory management. Replace them with std::unique_ptr<> when the conversion is simple. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
This commit is contained in:
@@ -69,7 +69,7 @@ private:
|
||||
|
||||
struct udev *udev_;
|
||||
struct udev_monitor *monitor_;
|
||||
EventNotifier *notifier_;
|
||||
std::unique_ptr<EventNotifier> notifier_;
|
||||
|
||||
std::set<dev_t> orphans_;
|
||||
std::unordered_set<dev_t> devices_;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <vector>
|
||||
@@ -53,7 +54,7 @@ private:
|
||||
UniqueFD fd_;
|
||||
bool headerReceived_;
|
||||
struct Header header_;
|
||||
EventNotifier *notifier_;
|
||||
std::unique_ptr<EventNotifier> notifier_;
|
||||
};
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
@@ -89,7 +89,7 @@ private:
|
||||
std::string deviceNode_;
|
||||
UniqueFD fd_;
|
||||
|
||||
EventNotifier *fdEventNotifier_;
|
||||
std::unique_ptr<EventNotifier> fdEventNotifier_;
|
||||
bool frameStartEnabled_;
|
||||
};
|
||||
|
||||
|
||||
@@ -280,10 +280,10 @@ private:
|
||||
enum v4l2_buf_type bufferType_;
|
||||
enum v4l2_memory memoryType_;
|
||||
|
||||
V4L2BufferCache *cache_;
|
||||
std::unique_ptr<V4L2BufferCache> cache_;
|
||||
std::map<unsigned int, FrameBuffer *> queuedBuffers_;
|
||||
|
||||
EventNotifier *fdBufferNotifier_;
|
||||
std::unique_ptr<EventNotifier> fdBufferNotifier_;
|
||||
|
||||
State state_;
|
||||
std::optional<unsigned int> firstFrame_;
|
||||
@@ -301,14 +301,14 @@ public:
|
||||
int open();
|
||||
void close();
|
||||
|
||||
V4L2VideoDevice *output() { return output_; }
|
||||
V4L2VideoDevice *capture() { return capture_; }
|
||||
V4L2VideoDevice *output() { return output_.get(); }
|
||||
V4L2VideoDevice *capture() { return capture_.get(); }
|
||||
|
||||
private:
|
||||
std::string deviceNode_;
|
||||
|
||||
V4L2VideoDevice *output_;
|
||||
V4L2VideoDevice *capture_;
|
||||
std::unique_ptr<V4L2VideoDevice> output_;
|
||||
std::unique_ptr<V4L2VideoDevice> capture_;
|
||||
};
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
Reference in New Issue
Block a user