From 39b2d3e152c6e6bca0c76e4f2198a42b61dc84b3 Mon Sep 17 00:00:00 2001
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Date: Thu, 26 Jan 2023 13:39:49 +0100
Subject: [PATCH] bindings: cxx: don't shift raw pointers around

There are two leftover instances where we return raw C pointers from
local functions. For safety and consistency with the rest of the code
convert those functions to return unique_ptr.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/cxx/edge-event-buffer.cpp | 4 ++--
 bindings/cxx/line-config.cpp       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bindings/cxx/edge-event-buffer.cpp b/bindings/cxx/edge-event-buffer.cpp
index 3c551df..c7347a2 100644
--- a/bindings/cxx/edge-event-buffer.cpp
+++ b/bindings/cxx/edge-event-buffer.cpp
@@ -11,9 +11,9 @@ namespace gpiod {
 
 namespace {
 
-::gpiod_edge_event_buffer* make_edge_event_buffer(unsigned int capacity)
+edge_event_buffer_ptr make_edge_event_buffer(unsigned int capacity)
 {
-	::gpiod_edge_event_buffer* buffer = ::gpiod_edge_event_buffer_new(capacity);
+	edge_event_buffer_ptr buffer(::gpiod_edge_event_buffer_new(capacity));
 	if (!buffer)
 		throw_from_errno("unable to allocate the edge event buffer");
 
diff --git a/bindings/cxx/line-config.cpp b/bindings/cxx/line-config.cpp
index 0ab54f4..1179e0a 100644
--- a/bindings/cxx/line-config.cpp
+++ b/bindings/cxx/line-config.cpp
@@ -14,9 +14,9 @@ namespace gpiod {
 
 namespace {
 
-::gpiod_line_config* make_line_config()
+line_config_ptr make_line_config()
 {
-	::gpiod_line_config *config = ::gpiod_line_config_new();
+	line_config_ptr config(::gpiod_line_config_new());
 	if (!config)
 		throw_from_errno("Unable to allocate the line config object");
 
-- 
2.30.2