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>
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 */