src.ctf.fs: use std::string in build_index_from_idx_file
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 9 Jun 2022 19:48:57 +0000 (15:48 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Aug 2022 16:06:16 +0000 (12:06 -0400)
Change-Id: Ifdb2c818f66efbc328b095408ae2834646fba4fe
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8310
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/ctf/fs-src/data-stream-file.cpp

index 4d3247399405029c8201eb439432fa69e109b6ed..67ef4d8659a38d6479e0061b6c7987ff36c56ad3 100644 (file)
@@ -461,7 +461,7 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
     int ret;
     bt2_common::GCharUP directory;
     bt2_common::GCharUP basename;
-    GString *index_basename = NULL;
+    std::string index_basename;
     bt2_common::GCharUP index_file_path;
     GMappedFile *mapped_file = NULL;
     gsize filesize;
@@ -506,14 +506,10 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
         goto error;
     }
 
-    index_basename = g_string_new(basename.get());
-    if (!index_basename) {
-        BT_CLOGE_STR("Cannot allocate index file basename string");
-        goto error;
-    }
+    index_basename = basename.get();
+    index_basename += ".idx";
 
-    g_string_append(index_basename, ".idx");
-    index_file_path.reset(g_build_filename(directory.get(), "index", index_basename->str, NULL));
+    index_file_path.reset(g_build_filename(directory.get(), "index", index_basename.c_str(), NULL));
     mapped_file = g_mapped_file_new(index_file_path.get(), FALSE, NULL);
     if (!mapped_file) {
         BT_CLOGD("Cannot create new mapped file %s", index_file_path.get());
@@ -644,9 +640,6 @@ static ctf_fs_ds_index::UP build_index_from_idx_file(struct ctf_fs_ds_file *ds_f
         goto error;
     }
 end:
-    if (index_basename) {
-        g_string_free(index_basename, TRUE);
-    }
     if (mapped_file) {
         g_mapped_file_unref(mapped_file);
     }
This page took 0.024689 seconds and 5 git commands to generate.