struct ctf_fs_ds_group_medops_data
{
/* Weak, set once at creation time. */
- struct ctf_fs_ds_file_group *ds_file_group;
+ struct ctf_fs_ds_file_group *ds_file_group = nullptr;
/*
* Index (as in element rank) of the index entry of ds_file_groups'
* index we will read next (so, the one after the one we are reading
* right now).
*/
- guint next_index_entry_index;
+ guint next_index_entry_index = 0;
/*
* File we are currently reading. Changes whenever we switch to
*
* Owned by this.
*/
- struct ctf_fs_ds_file *file;
+ struct ctf_fs_ds_file *file = nullptr;
/* Weak, for context / logging / appending causes. */
- bt_self_message_iterator *self_msg_iter;
- bt_logging_level log_level;
+ bt_self_message_iterator *self_msg_iter = nullptr;
+ bt_logging_level log_level = (bt_logging_level) 0;
};
static enum ctf_msg_iter_medium_status medop_group_request_bytes(size_t request_sz,
ctf_fs_ds_file_destroy(data->file);
- g_free(data);
+ delete data;
end:
return;
struct ctf_fs_ds_file_group *ds_file_group, bt_self_message_iterator *self_msg_iter,
bt_logging_level log_level, struct ctf_fs_ds_group_medops_data **out)
{
- struct ctf_fs_ds_group_medops_data *data;
- enum ctf_msg_iter_medium_status status;
-
BT_ASSERT(self_msg_iter);
BT_ASSERT(ds_file_group);
BT_ASSERT(ds_file_group->index);
BT_ASSERT(ds_file_group->index->entries->len > 0);
- data = g_new0(struct ctf_fs_ds_group_medops_data, 1);
- if (!data) {
- BT_MSG_ITER_LOGE_APPEND_CAUSE(self_msg_iter,
- "Failed to allocate a struct ctf_fs_ds_group_medops_data");
- status = CTF_MSG_ITER_MEDIUM_STATUS_MEMORY_ERROR;
- goto error;
- }
-
+ ctf_fs_ds_group_medops_data *data = new ctf_fs_ds_group_medops_data;
data->ds_file_group = ds_file_group;
data->self_msg_iter = self_msg_iter;
data->log_level = log_level;
*/
*out = data;
- status = CTF_MSG_ITER_MEDIUM_STATUS_OK;
- goto end;
-
-error:
- ctf_fs_ds_group_medops_data_destroy(data);
-
-end:
- return status;
+ return CTF_MSG_ITER_MEDIUM_STATUS_OK;
}
void ctf_fs_ds_group_medops_data_reset(struct ctf_fs_ds_group_medops_data *data)
.borrow_stream = medop_group_borrow_stream,
};
-static struct ctf_fs_ds_index_entry *ctf_fs_ds_index_entry_create(bt_self_component *self_comp,
- bt_logging_level log_level)
+static void ctf_fs_ds_index_entry_destroy(ctf_fs_ds_index_entry *entry)
{
- struct ctf_fs_ds_index_entry *entry;
-
- entry = g_new0(struct ctf_fs_ds_index_entry, 1);
- if (!entry) {
- BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to allocate a ctf_fs_ds_index_entry.");
- goto end;
- }
+ delete entry;
+}
+static struct ctf_fs_ds_index_entry *ctf_fs_ds_index_entry_create()
+{
+ ctf_fs_ds_index_entry *entry = new ctf_fs_ds_index_entry;
entry->packet_seq_num = UINT64_MAX;
-end:
return entry;
}
goto error;
}
- index_entry = ctf_fs_ds_index_entry_create(ds_file->self_comp, ds_file->log_level);
+ index_entry = ctf_fs_ds_index_entry_create();
if (!index_entry) {
BT_COMP_LOGE_APPEND_CAUSE(ds_file->self_comp,
"Failed to create a ctf_fs_ds_index_entry.");
return index;
error:
ctf_fs_ds_index_destroy(index);
- g_free(index_entry);
+ ctf_fs_ds_index_entry_destroy(index_entry);
index = NULL;
goto end;
}
goto error;
}
- index_entry = ctf_fs_ds_index_entry_create(ds_file->self_comp, ds_file->log_level);
+ index_entry = ctf_fs_ds_index_entry_create();
if (!index_entry) {
BT_COMP_LOGE_APPEND_CAUSE(ds_file->self_comp,
"Failed to create a ctf_fs_ds_index_entry.");
ret = init_index_entry(index_entry, ds_file, &props, current_packet_size_bytes,
current_packet_offset_bytes);
if (ret) {
- g_free(index_entry);
+ ctf_fs_ds_index_entry_destroy(index_entry);
goto error;
}
{
int ret;
const size_t offset_align = bt_mmap_get_offset_align_size(log_level);
- struct ctf_fs_ds_file *ds_file = g_new0(struct ctf_fs_ds_file, 1);
+ ctf_fs_ds_file *ds_file = new ctf_fs_ds_file;
if (!ds_file) {
goto error;
struct ctf_fs_ds_index *ctf_fs_ds_index_create(bt_logging_level log_level,
bt_self_component *self_comp)
{
- struct ctf_fs_ds_index *index = g_new0(struct ctf_fs_ds_index, 1);
-
- if (!index) {
- BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, log_level, self_comp, "Failed to allocate index");
- goto error;
- }
-
- index->entries = g_ptr_array_new_with_free_func((GDestroyNotify) g_free);
+ ctf_fs_ds_index *index = new ctf_fs_ds_index;
+ index->entries = g_ptr_array_new_with_free_func((GDestroyNotify) ctf_fs_ds_index_entry_destroy);
if (!index->entries) {
BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, log_level, self_comp,
"Failed to allocate index entries.");
ctf_fs_file_destroy(ds_file->file);
}
- g_free(ds_file);
+ delete ds_file;
}
void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index)
if (index->entries) {
g_ptr_array_free(index->entries, TRUE);
}
- g_free(index);
+
+ delete index;
}