src.ctf.lttng-live: make live_viewer_connection::{relay_hostname,target_hostname...
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 29 Jan 2024 21:15:18 +0000 (16:15 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
These values come from GStrings from the common code, not yet C++-ified,
so it's simpler for now to use GStringUP to automatically manage the
GString lifetimes locally.  If the common code ever becomes C++, it can
all be replaced with std::string.

Change-Id: I913ab51488fc934cd049e530a2b7583cc1cefff6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8470
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12385
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/lttng-live/viewer-connection.cpp
src/plugins/ctf/lttng-live/viewer-connection.hpp

index 5bb7007f33cc56d5a9f385f9eb140247d56e2e1f..0b9f71324d98c3ee34ed7381a07f1a111f148eec 100644 (file)
@@ -241,10 +241,10 @@ static int parse_url(struct live_viewer_connection *viewer_connection)
                                      error_buf);
         goto end;
     }
-    viewer_connection->proto = lttng_live_url_parts.proto;
+    viewer_connection->proto.reset(lttng_live_url_parts.proto);
     lttng_live_url_parts.proto = NULL;
 
-    viewer_connection->relay_hostname = lttng_live_url_parts.hostname;
+    viewer_connection->relay_hostname.reset(lttng_live_url_parts.hostname);
     lttng_live_url_parts.hostname = NULL;
 
     if (lttng_live_url_parts.port >= 0) {
@@ -253,11 +253,11 @@ static int parse_url(struct live_viewer_connection *viewer_connection)
         viewer_connection->port = LTTNG_DEFAULT_NETWORK_VIEWER_PORT;
     }
 
-    viewer_connection->target_hostname = lttng_live_url_parts.target_hostname;
+    viewer_connection->target_hostname.reset(lttng_live_url_parts.target_hostname);
     lttng_live_url_parts.target_hostname = NULL;
 
     if (lttng_live_url_parts.session_name) {
-        viewer_connection->session_name = lttng_live_url_parts.session_name;
+        viewer_connection->session_name.reset(lttng_live_url_parts.session_name);
         lttng_live_url_parts.session_name = NULL;
     }
 
@@ -1642,22 +1642,6 @@ void live_viewer_connection_destroy(struct live_viewer_connection *viewer_connec
 
     lttng_live_disconnect_viewer(viewer_connection);
 
-    if (viewer_connection->relay_hostname) {
-        g_string_free(viewer_connection->relay_hostname, true);
-    }
-
-    if (viewer_connection->target_hostname) {
-        g_string_free(viewer_connection->target_hostname, true);
-    }
-
-    if (viewer_connection->session_name) {
-        g_string_free(viewer_connection->session_name, true);
-    }
-
-    if (viewer_connection->proto) {
-        g_string_free(viewer_connection->proto, true);
-    }
-
     delete viewer_connection;
 
     bt_socket_fini();
index 707ce80b6741a0db254f2028758b5c20074a7f2c..586dd7ff99bfe1bcab538c26da51b5c1fb87c9b8 100644 (file)
@@ -15,6 +15,7 @@
 #include <babeltrace2/babeltrace.h>
 
 #include "compat/socket.hpp"
+#include "cpp-common/bt2c/glib-up.hpp"
 #include "cpp-common/bt2c/logging.hpp"
 
 #define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
@@ -58,10 +59,10 @@ struct live_viewer_connection
 
     std::string url;
 
-    GString *relay_hostname = nullptr;
-    GString *target_hostname = nullptr;
-    GString *session_name = nullptr;
-    GString *proto = nullptr;
+    bt2c::GStringUP relay_hostname;
+    bt2c::GStringUP target_hostname;
+    bt2c::GStringUP session_name;
+    bt2c::GStringUP proto;
 
     BT_SOCKET control_sock {};
     int port = 0;
This page took 0.025561 seconds and 4 git commands to generate.