src.ctf.lttng-live: use GCharUP in lttng_live_component_create
[babeltrace.git] / src / plugins / ctf / lttng-live / lttng-live.cpp
index a6dfd2104cbb103585a43d163838ea025767a9b8..d3f2c22d1e6f368707f41d64f03453e0bb9eb2cf 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "common/assert.h"
 #include "cpp-common/bt2c/fmt.hpp"
+#include "cpp-common/bt2c/glib-up.hpp"
 #include "cpp-common/vendor/fmt/format.h"
 
 #include "plugins/common/muxing/muxing.h"
@@ -1968,20 +1969,12 @@ end:
     }
 }
 
-static void lttng_live_component_destroy_data(struct lttng_live_component *lttng_live)
-{
-    delete lttng_live;
-}
-
 void lttng_live_component_finalize(bt_self_component_source *component)
 {
     lttng_live_component *data = (lttng_live_component *) bt_self_component_get_data(
         bt_self_component_source_as_self_component(component));
 
-    if (!data) {
-        return;
-    }
-    lttng_live_component_destroy_data(data);
+    delete data;
 }
 
 static enum session_not_found_action
@@ -2036,6 +2029,7 @@ lttng_live_component_create(const bt_value *params, bt_self_component_source *se
         status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
         goto error;
     } else if (validation_status == BT_PARAM_VALIDATION_STATUS_VALIDATION_ERROR) {
+        bt2c::GCharUP errorFreer {validation_error};
         BT_CPPLOGE_APPEND_CAUSE_SPEC(logger, "{}", validation_error);
         status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
         goto error;
@@ -2064,11 +2058,9 @@ lttng_live_component_create(const bt_value *params, bt_self_component_source *se
     goto end;
 
 error:
-    lttng_live_component_destroy_data(lttng_live);
+    delete lttng_live;
     lttng_live = NULL;
 end:
-    g_free(validation_error);
-
     *component = lttng_live;
     return status;
 }
@@ -2099,7 +2091,7 @@ lttng_live_component_init(bt_self_component_source *self_comp_src,
         goto end;
 
 error:
-        lttng_live_component_destroy_data(lttng_live);
+        delete lttng_live;
         lttng_live = NULL;
 end:
         return ret;
This page took 0.024494 seconds and 4 git commands to generate.