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:
@@ -70,7 +70,7 @@ LOG_DEFINE_CATEGORY(IPCUnixSocket)
|
||||
*/
|
||||
|
||||
IPCUnixSocket::IPCUnixSocket()
|
||||
: headerReceived_(false), notifier_(nullptr)
|
||||
: headerReceived_(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ int IPCUnixSocket::bind(UniqueFD fd)
|
||||
return -EINVAL;
|
||||
|
||||
fd_ = std::move(fd);
|
||||
notifier_ = new EventNotifier(fd_.get(), EventNotifier::Read);
|
||||
notifier_ = std::make_unique<EventNotifier>(fd_.get(), EventNotifier::Read);
|
||||
notifier_->activated.connect(this, &IPCUnixSocket::dataNotifier);
|
||||
|
||||
return 0;
|
||||
@@ -146,8 +146,7 @@ void IPCUnixSocket::close()
|
||||
if (!isBound())
|
||||
return;
|
||||
|
||||
delete notifier_;
|
||||
notifier_ = nullptr;
|
||||
notifier_.reset();
|
||||
|
||||
fd_.reset();
|
||||
headerReceived_ = false;
|
||||
|
||||
Reference in New Issue
Block a user