src.ctf.lttng-live: make live_viewer_connection::{relay_hostname,target_hostname...
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 23 Jun 2022 15:13:31 +0000 (11:13 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Aug 2022 16:06:16 +0000 (12:06 -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>
src/plugins/ctf/lttng-live/viewer-connection.cpp
src/plugins/ctf/lttng-live/viewer-connection.hpp

index 0777064dbc0ed9cda3f0112045cde0be2482a37a..f1d0e2f5e2e38f4978a1349c015c7f4964b3f216 100644 (file)
@@ -337,10 +337,10 @@ static int parse_url(struct live_viewer_connection *viewer_connection)
         BT_CLOGE_APPEND_CAUSE("Invalid LTTng live URL format: %s", 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) {
@@ -349,11 +349,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;
     }
 
@@ -1727,22 +1727,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 2fa06ea3f9853148adf18c1a28bebe6d561daede..1b108deaf1574c0c6d71e3616d270fb3453e7a1a 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "common/macros.h"
 #include "compat/socket.h"
+#include "cpp-common/glib-up.hpp"
 #include "cpp-common/log-cfg.hpp"
 
 #define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
@@ -63,10 +64,10 @@ struct live_viewer_connection
 
     std::string url;
 
-    GString *relay_hostname = nullptr;
-    GString *target_hostname = nullptr;
-    GString *session_name = nullptr;
-    GString *proto = nullptr;
+    bt2_common::GStringUP relay_hostname;
+    bt2_common::GStringUP target_hostname;
+    bt2_common::GStringUP session_name;
+    bt2_common::GStringUP proto;
 
     BT_SOCKET control_sock {};
     int port = 0;
This page took 0.026194 seconds and 5 git commands to generate.