ctf_msg_iter_destroy(msg_iter_data->msg_iter);
}
- if (msg_iter_data->msg_iter_medops_data) {
- ctf_fs_ds_group_medops_data_destroy(msg_iter_data->msg_iter_medops_data);
- }
-
delete msg_iter_data;
}
try {
ctf_msg_iter_reset(msg_iter_data->msg_iter);
- ctf_fs_ds_group_medops_data_reset(msg_iter_data->msg_iter_medops_data);
+ ctf_fs_ds_group_medops_data_reset(msg_iter_data->msg_iter_medops_data.get());
return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK;
} catch (const std::bad_alloc&) {
medium_status =
ctf_fs_ds_group_medops_data_create(msg_iter_data->ds_file_group, self_msg_iter, logCfg,
- &msg_iter_data->msg_iter_medops_data);
+ msg_iter_data->msg_iter_medops_data);
BT_ASSERT(medium_status == CTF_MSG_ITER_MEDIUM_STATUS_OK ||
medium_status == CTF_MSG_ITER_MEDIUM_STATUS_ERROR ||
medium_status == CTF_MSG_ITER_MEDIUM_STATUS_MEMORY_ERROR);
msg_iter_data->msg_iter = ctf_msg_iter_create(
msg_iter_data->ds_file_group->ctf_fs_trace->metadata->tc,
bt_common_get_page_size(logCfg.logLevel()) * 8, ctf_fs_ds_group_medops,
- msg_iter_data->msg_iter_medops_data, self_msg_iter, logCfg);
+ msg_iter_data->msg_iter_medops_data.get(), self_msg_iter, logCfg);
if (!msg_iter_data->msg_iter) {
BT_CLOGE_APPEND_CAUSE("Cannot create a CTF message iterator.");
status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
struct ctf_fs_ds_file_group *ds_file_group = NULL;
ctf_fs_ds_file_group::UP new_ds_file_group;
int ret;
- struct ctf_fs_ds_file *ds_file = NULL;
ctf_fs_ds_file_info::UP ds_file_info;
ctf_fs_ds_index::UP index;
struct ctf_msg_iter *msg_iter = NULL;
* Create a temporary ds_file to read some properties about the data
* stream file.
*/
- ds_file = ctf_fs_ds_file_create(ctf_fs_trace, nonstd::nullopt, path, logCfg);
+ ctf_fs_ds_file::UP ds_file = ctf_fs_ds_file_create(ctf_fs_trace, nonstd::nullopt, path, logCfg);
if (!ds_file) {
goto error;
}
/* Create a temporary iterator to read the ds_file. */
msg_iter = ctf_msg_iter_create(ctf_fs_trace->metadata->tc,
bt_common_get_page_size(logCfg.logLevel()) * 8,
- ctf_fs_ds_file_medops, ds_file, nullptr, logCfg);
+ ctf_fs_ds_file_medops, ds_file.get(), nullptr, logCfg);
if (!msg_iter) {
BT_CLOGE_STR("Cannot create a CTF message iterator.");
goto error;
goto error;
}
- index = ctf_fs_ds_file_build_index(ds_file, ds_file_info.get(), msg_iter);
+ index = ctf_fs_ds_file_build_index(ds_file.get(), ds_file_info.get(), msg_iter);
if (!index) {
- BT_CLOGE_APPEND_CAUSE("Failed to index CTF stream file \'%s\'", ds_file->file->path->str);
+ BT_CLOGE_APPEND_CAUSE("Failed to index CTF stream file \'%s\'",
+ ds_file->file->path.c_str());
goto error;
}
ret = -1;
end:
- ctf_fs_ds_file_destroy(ds_file);
-
if (msg_iter) {
ctf_msg_iter_destroy(msg_iter);
}
}
while ((basename = g_dir_read_name(dir))) {
- struct ctf_fs_file *file;
-
if (strcmp(basename, CTF_FS_METADATA_FILENAME) == 0) {
/* Ignore the metadata stream. */
BT_CLOGI("Ignoring metadata file `%s" G_DIR_SEPARATOR_S "%s`", ctf_fs_trace->path->str,
}
/* Create the file. */
- file = ctf_fs_file_create(logCfg).release();
+ ctf_fs_file::UP file = ctf_fs_file_create(logCfg);
if (!file) {
BT_CLOGE_APPEND_CAUSE("Cannot create stream file object for file `%s" G_DIR_SEPARATOR_S
"%s`",
}
/* Create full path string. */
- g_string_append_printf(file->path, "%s" G_DIR_SEPARATOR_S "%s", ctf_fs_trace->path->str,
- basename);
- if (!g_file_test(file->path->str, G_FILE_TEST_IS_REGULAR)) {
- BT_CLOGI("Ignoring non-regular file `%s`", file->path->str);
- ctf_fs_file_destroy(file);
- file = NULL;
+ file->path = ctf_fs_trace->path->str;
+ file->path += G_DIR_SEPARATOR;
+ file->path += basename;
+
+ if (!g_file_test(file->path.c_str(), G_FILE_TEST_IS_REGULAR)) {
+ BT_CLOGI("Ignoring non-regular file `%s`", file->path.c_str());
continue;
}
- ret = ctf_fs_file_open(file, "rb");
+ ret = ctf_fs_file_open(file.get(), "rb");
if (ret) {
- BT_CLOGE_APPEND_CAUSE("Cannot open stream file `%s`", file->path->str);
+ BT_CLOGE_APPEND_CAUSE("Cannot open stream file `%s`", file->path.c_str());
goto error;
}
if (file->size == 0) {
/* Skip empty stream. */
- BT_CLOGI("Ignoring empty file `%s`", file->path->str);
- ctf_fs_file_destroy(file);
+ BT_CLOGI("Ignoring empty file `%s`", file->path.c_str());
continue;
}
- ret = add_ds_file_to_ds_file_group(ctf_fs_trace, file->path->str);
+ ret = add_ds_file_to_ds_file_group(ctf_fs_trace, file->path.c_str());
if (ret) {
BT_CLOGE_APPEND_CAUSE("Cannot add stream file `%s` to stream file group",
- file->path->str);
- ctf_fs_file_destroy(file);
+ file->path.c_str());
goto error;
}
-
- ctf_fs_file_destroy(file);
}
goto end;
int64_t *ts_ns)
{
enum ctf_msg_iter_status iter_status = CTF_MSG_ITER_STATUS_OK;
- struct ctf_fs_ds_file *ds_file = NULL;
struct ctf_msg_iter *msg_iter = NULL;
const bt2_common::LogCfg& logCfg = ctf_fs_trace->logCfg;
int ret = 0;
BT_ASSERT(index_entry);
BT_ASSERT(index_entry->path);
- ds_file = ctf_fs_ds_file_create(ctf_fs_trace, nonstd::nullopt, index_entry->path, logCfg);
+ ctf_fs_ds_file::UP ds_file =
+ ctf_fs_ds_file_create(ctf_fs_trace, nonstd::nullopt, index_entry->path, logCfg);
if (!ds_file) {
BT_CLOGE_APPEND_CAUSE("Failed to create a ctf_fs_ds_file");
ret = -1;
msg_iter = ctf_msg_iter_create(ctf_fs_trace->metadata->tc,
bt_common_get_page_size(logCfg.logLevel()) * 8,
- ctf_fs_ds_file_medops, ds_file, NULL, logCfg);
+ ctf_fs_ds_file_medops, ds_file.get(), NULL, logCfg);
if (!msg_iter) {
/* ctf_msg_iter_create() logs errors. */
ret = -1;
}
end:
- if (ds_file) {
- ctf_fs_ds_file_destroy(ds_file);
- }
if (msg_iter) {
ctf_msg_iter_destroy(msg_iter);
}