cpp-common: add GStringUP
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 9 Jun 2022 15:23:33 +0000 (11:23 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 11 Sep 2023 15:24:02 +0000 (11:24 -0400)
Add a type to automatically manage the lifetime of GString objects.

Change-Id: I60e08f7d62c290c0194ed0cd62b0d0491b9af2bd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8288
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10844
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/cpp-common/glib-up.hpp

index 92bbde09be560a16e04cdae1b1ce50860bcd4233..4ff0ed853f0498283ad193cb312bf3b993de3a6d 100644 (file)
@@ -25,6 +25,20 @@ struct GCharDeleter final
 
 using GCharUP = std::unique_ptr<gchar, internal::GCharDeleter>;
 
+namespace internal {
+
+struct GStringDeleter final
+{
+    void operator()(GString * const str)
+    {
+        g_string_free(str, TRUE);
+    }
+};
+
+} /* namespace internal */
+
+using GStringUP = std::unique_ptr<GString, internal::GStringDeleter>;
+
 } /* namespace bt2_common */
 
 #endif /* BABELTRACE_CPP_COMMON_GLIB_UP_HPP */
This page took 0.030396 seconds and 4 git commands to generate.