src.ctf.fs: make ctf_fs_ds_file_info::path an std::string
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 4 Dec 2023 20:06:58 +0000 (20:06 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Change-Id: If7e5c09024451b1c344a0446a75703929aff480e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8248
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12286

src/plugins/ctf/fs-src/data-stream-file.cpp
src/plugins/ctf/fs-src/data-stream-file.hpp
src/plugins/ctf/fs-src/fs.cpp

index 9f50f7ce584a4548cf932484210213c6d812810c..c1fcad2729d17b84768efbe14213489a282fc690 100644 (file)
@@ -613,7 +613,7 @@ static struct ctf_fs_ds_index *build_index_from_idx_file(struct ctf_fs_ds_file *
         }
 
         /* Set path to stream file. */
-        index_entry->path = file_info->path->str;
+        index_entry->path = file_info->path.c_str();
 
         index_entry->timestamp_begin = be64toh(file_index->timestamp_begin);
         index_entry->timestamp_end = be64toh(file_index->timestamp_end);
@@ -795,7 +795,7 @@ static struct ctf_fs_ds_index *build_index_from_stream_file(struct ctf_fs_ds_fil
         }
 
         /* Set path to stream file. */
-        index_entry->path = file_info->path->str;
+        index_entry->path = file_info->path.c_str();
 
         ret = init_index_entry(index_entry, ds_file, &props);
         if (ret) {
@@ -932,26 +932,15 @@ void ctf_fs_ds_file_info_destroy(struct ctf_fs_ds_file_info *ds_file_info)
         return;
     }
 
-    if (ds_file_info->path) {
-        g_string_free(ds_file_info->path, TRUE);
-    }
-
     delete ds_file_info;
 }
 
 struct ctf_fs_ds_file_info *ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns)
 {
     ctf_fs_ds_file_info *ds_file_info = new ctf_fs_ds_file_info;
-    ds_file_info->path = g_string_new(path);
-    if (!ds_file_info->path) {
-        ctf_fs_ds_file_info_destroy(ds_file_info);
-        ds_file_info = NULL;
-        goto end;
-    }
 
+    ds_file_info->path = path;
     ds_file_info->begin_ns = begin_ns;
-
-end:
     return ds_file_info;
 }
 
index 8f770705367a52b59fd6c26e0546bb71e1749e68..6b5c3db71efb0ca4715c42e345a0bbc69703b2bb 100644 (file)
@@ -8,6 +8,7 @@
 #define CTF_FS_DS_FILE_H
 
 #include <memory>
+#include <string>
 
 #include <glib.h>
 #include <stdio.h>
@@ -21,8 +22,7 @@
 
 struct ctf_fs_ds_file_info
 {
-    /* Owned by this. */
-    GString *path = nullptr;
+    std::string path;
 
     /* Guaranteed to be set, as opposed to the index. */
     int64_t begin_ns = 0;
index d49e987951186346d77a67aff4af30654821b04e..40ef74397f573842700c72fde73cd59c1a8636b6 100644 (file)
@@ -363,7 +363,7 @@ bt2c::GCharUP ctf_fs_make_port_name(struct ctf_fs_ds_file_group *ds_file_group)
         BT_ASSERT(ds_file_group->ds_file_infos->len == 1);
         struct ctf_fs_ds_file_info *ds_file_info =
             (struct ctf_fs_ds_file_info *) g_ptr_array_index(ds_file_group->ds_file_infos, 0);
-        g_string_append_printf(name, " | %s", ds_file_info->path->str);
+        g_string_append_printf(name, " | %s", ds_file_info->path.c_str());
     }
 
     return bt2c::GCharUP {g_string_free(name, FALSE)};
@@ -1724,7 +1724,7 @@ static bool compare_ds_file_groups_by_first_path(const ctf_fs_ds_file_group::UP&
     const ctf_fs_ds_file_info *first_ds_file_info_b =
         (const ctf_fs_ds_file_info *) ds_file_group_b->ds_file_infos->pdata[0];
 
-    return strcmp(first_ds_file_info_a->path->str, first_ds_file_info_b->path->str) < 0;
+    return first_ds_file_info_a->path < first_ds_file_info_b->path;
 }
 
 static gint compare_strings(gconstpointer p_a, gconstpointer p_b)
@@ -1884,7 +1884,7 @@ static GString *get_stream_instance_unique_name(struct ctf_fs_ds_file_group *ds_
      */
     BT_ASSERT(ds_file_group->ds_file_infos->len > 0);
     ds_file_info = (ctf_fs_ds_file_info *) g_ptr_array_index(ds_file_group->ds_file_infos, 0);
-    g_string_assign(name, ds_file_info->path->str);
+    g_string_assign(name, ds_file_info->path.c_str());
 
 end:
     return name;
This page took 0.026783 seconds and 4 git commands to generate.