/* Binary class reader */
struct bt_bfcr
{
- bt_logging_level log_level;
+ bt_logging_level log_level = static_cast<bt_logging_level>(0);
/* Weak */
- bt_self_component *self_comp;
+ bt_self_component *self_comp = nullptr;
/* BFCR stack */
- struct stack *stack;
+ struct stack *stack = nullptr;
/* Current basic field class */
- struct ctf_field_class *cur_basic_field_class;
+ struct ctf_field_class *cur_basic_field_class = nullptr;
/* Current state */
- enum bfcr_state state;
+ enum bfcr_state state = static_cast<bfcr_state>(0);
/*
* Last basic field class's byte order.
* This is set to CTF_BYTE_ORDER_UNKNOWN on reset and when the last
* basic field class was a string class.
*/
- enum ctf_byte_order last_bo;
+ enum ctf_byte_order last_bo = CTF_BYTE_ORDER_UNKNOWN;
/* Current byte order (copied to last_bo after a successful read) */
- enum ctf_byte_order cur_bo;
+ enum ctf_byte_order cur_bo = CTF_BYTE_ORDER_UNKNOWN;
/* Stitch buffer infos */
struct
{
/* Stitch buffer */
- uint8_t buf[16];
+ uint8_t buf[16] {};
/* Offset, within stitch buffer, of first bit */
- size_t offset;
+ size_t offset = 0;
/* Length (bits) of data in stitch buffer from offset */
- size_t at;
+ size_t at = 0;
} stitch;
/* User buffer infos */
struct
{
/* Address */
- const uint8_t *addr;
+ const uint8_t *addr = nullptr;
/* Offset of data from address (bits) */
- size_t offset;
+ size_t offset = 0;
/* Current position from offset (bits) */
- size_t at;
+ size_t at = 0;
/* Offset of offset within whole packet (bits) */
- size_t packet_offset;
+ size_t packet_offset = 0;
/* Data size in buffer (bits) */
- size_t sz;
+ size_t sz = 0;
/* Buffer size (bytes) */
- size_t buf_sz;
+ size_t buf_sz = 0;
} buf;
/* User stuff */
struct
{
/* Callback functions */
- struct bt_bfcr_cbs cbs;
+ bt_bfcr_cbs cbs {};
/* Private data */
- void *data;
+ void *data = nullptr;
} user;
};
struct bt_bfcr *bt_bfcr_create(struct bt_bfcr_cbs cbs, void *data, bt_logging_level log_level,
bt_self_component *self_comp)
{
- struct bt_bfcr *bfcr;
-
BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG, log_level, self_comp,
"Creating binary field class reader (BFCR).");
- bfcr = g_new0(struct bt_bfcr, 1);
- if (!bfcr) {
- BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, log_level, self_comp,
- "Failed to allocate one binary class reader.");
- goto end;
- }
+ bt_bfcr *bfcr = new bt_bfcr;
bfcr->log_level = log_level;
bfcr->self_comp = self_comp;
bfcr->stack = stack_new(bfcr);
}
BT_COMP_LOGD("Destroying BFCR: addr=%p", bfcr);
- g_free(bfcr);
+ delete bfcr;
}
static void reset(struct bt_bfcr *bfcr)
*/
struct resolve_context
{
- bt_logging_level log_level;
+ bt_logging_level log_level = (bt_logging_level) 0;
/* Weak, exactly one of these must be set */
- bt_self_component *self_comp;
- bt_self_component_class *self_comp_class;
+ bt_self_component *self_comp = nullptr;
+ bt_self_component_class *self_comp_class = nullptr;
- struct ctf_trace_class *tc;
- struct ctf_stream_class *sc;
- struct ctf_event_class *ec;
+ struct ctf_trace_class *tc = nullptr;
+ struct ctf_stream_class *sc = nullptr;
+ struct ctf_event_class *ec = nullptr;
struct
{
- struct ctf_field_class *packet_header;
- struct ctf_field_class *packet_context;
- struct ctf_field_class *event_header;
- struct ctf_field_class *event_common_context;
- struct ctf_field_class *event_spec_context;
- struct ctf_field_class *event_payload;
+ struct ctf_field_class *packet_header = nullptr;
+ struct ctf_field_class *packet_context = nullptr;
+ struct ctf_field_class *event_header = nullptr;
+ struct ctf_field_class *event_common_context = nullptr;
+ struct ctf_field_class *event_spec_context = nullptr;
+ struct ctf_field_class *event_payload = nullptr;
} scopes;
/* Root scope being visited */
- enum ctf_scope root_scope;
- field_class_stack_t *field_class_stack;
- struct ctf_field_class *cur_fc;
+ enum ctf_scope root_scope = CTF_SCOPE_PACKET_HEADER;
+ field_class_stack_t *field_class_stack = nullptr;
+ struct ctf_field_class *cur_fc = nullptr;
};
/* TSDL dynamic scope prefixes as defined in CTF Section 7.3.2 */
struct ctf_metadata_decoder
{
- struct ctf_scanner *scanner;
- GString *text;
- struct ctf_visitor_generate_ir *visitor;
- bt_uuid_t uuid;
- bool is_uuid_set;
- int bo;
+ struct ctf_scanner *scanner = nullptr;
+ GString *text = nullptr;
+ struct ctf_visitor_generate_ir *visitor = nullptr;
+ bt_uuid_t uuid {};
+ bool is_uuid_set = false;
+ int bo = 0;
struct ctf_metadata_decoder_config config;
struct meta_log_config log_cfg;
- bool has_checked_plaintext_signature;
+ bool has_checked_plaintext_signature = false;
};
struct packet_header
struct ctf_metadata_decoder *
ctf_metadata_decoder_create(const struct ctf_metadata_decoder_config *config)
{
- struct ctf_metadata_decoder *mdec = g_new0(struct ctf_metadata_decoder, 1);
-
BT_ASSERT(config);
BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG, config->log_level, config->self_comp,
"Creating CTF metadata decoder: "
"clock-class-offset-ns=%" PRId64,
config->clock_class_offset_s, config->clock_class_offset_ns);
- if (!mdec) {
- BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, config->log_level, config->self_comp,
- "Failed to allocate one CTF metadata decoder.");
- goto end;
- }
-
+ ctf_metadata_decoder *mdec = new ctf_metadata_decoder;
mdec->log_cfg.log_level = config->log_level;
mdec->log_cfg.self_comp = config->self_comp;
mdec->log_cfg.self_comp_class = config->self_comp_class;
BT_COMP_LOGD("Destroying CTF metadata decoder: addr=%p", mdec);
ctf_visitor_generate_ir_destroy(mdec->visitor);
- g_free(mdec);
+ delete mdec;
}
enum ctf_metadata_decoder_status
struct ctf_metadata_decoder_config
{
/* Active log level to use */
- bt_logging_level log_level;
+ bt_logging_level log_level = (bt_logging_level) 0;
/*
* Component or component class to use for logging (exactly one of
* them must be non-`NULL`); weak
*/
- bt_self_component *self_comp;
- bt_self_component_class *self_comp_class;
+ bt_self_component *self_comp = nullptr;
+ bt_self_component_class *self_comp_class = nullptr;
/* Additional clock class offset to apply */
- int64_t clock_class_offset_s;
- int64_t clock_class_offset_ns;
- bool force_clock_class_origin_unix_epoch;
+ int64_t clock_class_offset_s = 0;
+ int64_t clock_class_offset_ns = 0;
+ bool force_clock_class_origin_unix_epoch = false;
/* True to create trace class objects */
- bool create_trace_class;
+ bool create_trace_class = false;
/*
* True to keep the plain text when content is appended with
* ctf_metadata_decoder_append_content().
*/
- bool keep_plain_text;
+ bool keep_plain_text = false;
};
/*
struct meta_log_config log_cfg;
/* Trace IR trace class being filled (owned by this) */
- bt_trace_class *trace_class;
+ bt_trace_class *trace_class = nullptr;
/* CTF meta trace being filled (owned by this) */
- struct ctf_trace_class *ctf_tc;
+ struct ctf_trace_class *ctf_tc = nullptr;
/* Current declaration scope (top of the stack) (owned by this) */
- struct ctx_decl_scope *current_scope;
+ struct ctx_decl_scope *current_scope = nullptr;
/* True if trace declaration is visited */
- bool is_trace_visited;
+ bool is_trace_visited = false;
/* True if this is an LTTng trace */
- bool is_lttng;
+ bool is_lttng = false;
/* Config passed by the user */
struct ctf_metadata_decoder_config decoder_config;
ctf_trace_class_destroy(ctx->ctf_tc);
}
- g_free(ctx);
+ delete ctx;
end:
return;
static struct ctf_visitor_generate_ir *
ctx_create(const struct ctf_metadata_decoder_config *decoder_config)
{
- struct ctf_visitor_generate_ir *ctx = NULL;
-
BT_ASSERT(decoder_config);
- ctx = g_new0(struct ctf_visitor_generate_ir, 1);
- if (!ctx) {
- BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, decoder_config->log_level, decoder_config->self_comp,
- "Failed to allocate one visitor context.");
- goto error;
- }
-
+ ctf_visitor_generate_ir *ctx = new ctf_visitor_generate_ir;
ctx->log_cfg.log_level = decoder_config->log_level;
ctx->log_cfg.self_comp = decoder_config->self_comp;
ctx->log_cfg.self_comp_class = decoder_config->self_comp_class;
struct end_of_packet_snapshots
{
- uint64_t discarded_events;
- uint64_t packets;
- uint64_t beginning_clock;
- uint64_t end_clock;
+ uint64_t discarded_events = 0;
+ uint64_t packets = 0;
+ uint64_t beginning_clock = 0;
+ uint64_t end_clock = 0;
};
/* CTF message iterator */
struct ctf_msg_iter
{
/* Visit stack */
- struct stack *stack;
+ struct stack *stack = nullptr;
/* Current message iterator to create messages (weak) */
- bt_self_message_iterator *self_msg_iter;
+ bt_self_message_iterator *self_msg_iter = nullptr;
/*
* True if library objects are unavailable during the decoding and
* should not be created/used.
*/
- bool dry_run;
+ bool dry_run = false;
/*
* Current dynamic scope field pointer.
* This is set by read_dscope_begin_state() and contains the
* value of one of the pointers in `dscopes` below.
*/
- bt_field *cur_dscope_field;
+ bt_field *cur_dscope_field = nullptr;
/*
* True if we're done filling a string field from a text
* array/sequence payload.
*/
- bool done_filling_string;
+ bool done_filling_string = false;
/* Trace and classes */
/* True to set IR fields */
- bool set_ir_fields;
+ bool set_ir_fields = false;
struct
{
- struct ctf_trace_class *tc;
- struct ctf_stream_class *sc;
- struct ctf_event_class *ec;
+ struct ctf_trace_class *tc = nullptr;
+ struct ctf_stream_class *sc = nullptr;
+ struct ctf_event_class *ec = nullptr;
} meta;
/* Current packet (NULL if not created yet) */
- bt_packet *packet;
+ bt_packet *packet = nullptr;
/* Current stream (NULL if not set yet) */
- bt_stream *stream;
+ bt_stream *stream = nullptr;
/* Current event (NULL if not created yet) */
- bt_event *event;
+ bt_event *event = nullptr;
/* Current event message (NULL if not created yet) */
- bt_message *event_msg;
+ bt_message *event_msg = nullptr;
/*
* True if we need to emit a packet beginning message before we emit
* the next event message or the packet end message.
*/
- bool emit_delayed_packet_beginning_msg;
+ bool emit_delayed_packet_beginning_msg = false;
/*
* True if this is the first packet we are reading, and therefore if we
* should emit a stream beginning message.
*/
- bool emit_stream_beginning_message;
+ bool emit_stream_beginning_message = false;
/*
* True if we need to emit a stream end message at the end of the
* never send a stream beginning message which removes the need to emit
* a stream end message.
*/
- bool emit_stream_end_message;
+ bool emit_stream_end_message = false;
/* Database of current dynamic scopes */
struct
{
- bt_field *stream_packet_context;
- bt_field *event_common_context;
- bt_field *event_spec_context;
- bt_field *event_payload;
+ bt_field *stream_packet_context = nullptr;
+ bt_field *event_common_context = nullptr;
+ bt_field *event_spec_context = nullptr;
+ bt_field *event_payload = nullptr;
} dscopes;
/* Current state */
- enum state state;
+ enum state state = STATE_INIT;
/* Current medium buffer data */
struct
{
/* Last address provided by medium */
- const uint8_t *addr;
+ const uint8_t *addr = nullptr;
/* Buffer size provided by medium (bytes) */
- size_t sz;
+ size_t sz = 0;
/* Offset within whole packet of addr (bits) */
- size_t packet_offset;
+ size_t packet_offset = 0;
/* Current position from addr (bits) */
- size_t at;
+ size_t at = 0;
/* Position of the last event header from addr (bits) */
- size_t last_eh_at;
+ size_t last_eh_at = 0;
} buf;
/* Binary type reader */
- struct bt_bfcr *bfcr;
+ struct bt_bfcr *bfcr = nullptr;
/* Current medium data */
struct
{
struct ctf_msg_iter_medium_ops medops;
- size_t max_request_sz;
- void *data;
+ size_t max_request_sz = 0;
+ void *data = nullptr;
} medium;
/* Current packet size (bits) (-1 if unknown) */
- int64_t cur_exp_packet_total_size;
+ int64_t cur_exp_packet_total_size = 0;
/* Current content size (bits) (-1 if unknown) */
- int64_t cur_exp_packet_content_size;
+ int64_t cur_exp_packet_content_size = 0;
/* Current stream class ID */
- int64_t cur_stream_class_id;
+ int64_t cur_stream_class_id = 0;
/* Current event class ID */
- int64_t cur_event_class_id;
+ int64_t cur_event_class_id = 0;
/* Current data stream ID */
- int64_t cur_data_stream_id;
+ int64_t cur_data_stream_id = 0;
/*
* Offset, in the underlying media, of the current packet's
* start (-1 if unknown).
*/
- off_t cur_packet_offset;
+ off_t cur_packet_offset = 0;
/* Default clock's current value */
- uint64_t default_clock_snapshot;
+ uint64_t default_clock_snapshot = 0;
/* End of current packet snapshots */
struct end_of_packet_snapshots snapshots;
struct end_of_packet_snapshots prev_packet_snapshots;
/* Stored values (for sequence lengths, variant tags) */
- GArray *stored_values;
+ GArray *stored_values = nullptr;
/* Iterator's current log level */
- bt_logging_level log_level;
+ bt_logging_level log_level = (bt_logging_level) 0;
/* Iterator's owning self component, or `NULL` if none (query) */
- bt_self_component *self_comp;
+ bt_self_component *self_comp = nullptr;
};
static inline const char *state_string(enum state state)
bt_logging_level log_level, bt_self_component *self_comp,
bt_self_message_iterator *self_msg_iter)
{
- struct ctf_msg_iter *msg_it = NULL;
struct bt_bfcr_cbs cbs = {
.classes =
{
"trace-addr=%p, max-request-size=%zu, "
"data=%p, log-level=%s",
tc, max_request_sz, data, bt_common_logging_level_string(log_level));
- msg_it = g_new0(struct ctf_msg_iter, 1);
- if (!msg_it) {
- BT_COMP_LOG_CUR_LVL(BT_LOG_ERROR, log_level, self_comp,
- "Failed to allocate one CTF plugin message iterator.");
- goto end;
- }
+
+ ctf_msg_iter *msg_it = new ctf_msg_iter;
msg_it->self_comp = self_comp;
msg_it->self_msg_iter = self_msg_iter;
msg_it->log_level = log_level;
g_array_free(msg_it->stored_values, TRUE);
}
- g_free(msg_it);
+ delete msg_it;
}
enum ctf_msg_iter_status ctf_msg_iter_get_next_message(struct ctf_msg_iter *msg_it,
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;
}
struct ctf_fs_ds_file_info
{
/* Owned by this. */
- GString *path;
+ GString *path = nullptr;
/* Guaranteed to be set, as opposed to the index. */
- int64_t begin_ns;
+ int64_t begin_ns = 0;
};
struct ctf_fs_ds_file
{
- bt_logging_level log_level;
+ bt_logging_level log_level = (bt_logging_level) 0;
/* Weak */
- bt_self_component *self_comp;
+ bt_self_component *self_comp = nullptr;
/* Weak */
- struct ctf_fs_metadata *metadata;
+ struct ctf_fs_metadata *metadata = nullptr;
/* Owned by this */
- struct ctf_fs_file *file;
+ struct ctf_fs_file *file = nullptr;
/* Owned by this */
- bt_stream *stream;
+ bt_stream *stream = nullptr;
- void *mmap_addr;
+ void *mmap_addr = nullptr;
/*
* Max length of chunk to mmap() when updating the current mapping.
* This value must be page-aligned.
*/
- size_t mmap_max_len;
+ size_t mmap_max_len = 0;
/* Length of the current mapping. Never exceeds the file's length. */
- size_t mmap_len;
+ size_t mmap_len = 0;
/* Offset in the file where the current mapping starts. */
- off_t mmap_offset_in_file;
+ off_t mmap_offset_in_file = 0;
/*
* Offset, in the current mapping, of the address to return on the next
* request.
*/
- off_t request_offset_in_mapping;
+ off_t request_offset_in_mapping = 0;
};
struct ctf_fs_ds_file *ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace, bt_stream *stream,
g_string_free(file->path, TRUE);
}
- g_free(file);
+ delete file;
}
struct ctf_fs_file *ctf_fs_file_create(bt_logging_level log_level, bt_self_component *self_comp)
{
- struct ctf_fs_file *file = g_new0(struct ctf_fs_file, 1);
-
- if (!file) {
- goto error;
- }
-
+ ctf_fs_file *file = new ctf_fs_file;
file->log_level = log_level;
file->self_comp = self_comp;
file->path = g_string_new(NULL);
ctf_fs_ds_group_medops_data_destroy(msg_iter_data->msg_iter_medops_data);
}
- g_free(msg_iter_data);
+ delete msg_iter_data;
}
static bt_message_iterator_class_next_method_status
bt_self_component_port_output *self_port)
{
struct ctf_fs_port_data *port_data;
- struct ctf_fs_msg_iter_data *msg_iter_data = NULL;
bt_message_iterator_class_initialize_method_status status;
bt_logging_level log_level;
enum ctf_msg_iter_medium_status medium_status;
bt_self_component_port_output_as_self_component_port(self_port));
BT_ASSERT(port_data);
log_level = port_data->ctf_fs->log_level;
- msg_iter_data = g_new0(struct ctf_fs_msg_iter_data, 1);
- if (!msg_iter_data) {
- status = BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
- goto error;
- }
+ ctf_fs_msg_iter_data *msg_iter_data = new ctf_fs_msg_iter_data;
msg_iter_data->log_level = log_level;
msg_iter_data->self_comp = self_comp;
msg_iter_data->self_msg_iter = self_msg_iter;
if (ctf_fs_trace->metadata) {
ctf_fs_metadata_fini(ctf_fs_trace->metadata);
- g_free(ctf_fs_trace->metadata);
+ delete ctf_fs_trace->metadata;
}
- g_free(ctf_fs_trace);
+ delete ctf_fs_trace;
}
void ctf_fs_destroy(struct ctf_fs_component *ctf_fs)
g_ptr_array_free(ctf_fs->port_data, TRUE);
}
- g_free(ctf_fs);
+ delete ctf_fs;
}
static void port_data_destroy(struct ctf_fs_port_data *port_data)
return;
}
- g_free(port_data);
+ delete port_data;
}
static void port_data_destroy_notifier(void *data)
struct ctf_fs_component *ctf_fs_component_create(bt_logging_level log_level)
{
- struct ctf_fs_component *ctf_fs;
-
- ctf_fs = g_new0(struct ctf_fs_component, 1);
- if (!ctf_fs) {
- goto error;
- }
-
+ ctf_fs_component *ctf_fs = new ctf_fs_component;
ctf_fs->log_level = log_level;
ctf_fs->port_data = g_ptr_array_new_with_free_func(port_data_destroy_notifier);
if (!ctf_fs->port_data) {
BT_COMP_LOGI("Creating one port named `%s`", port_name);
/* Create output port for this file */
- port_data = g_new0(struct ctf_fs_port_data, 1);
- if (!port_data) {
- goto error;
- }
-
+ port_data = new ctf_fs_port_data;
port_data->ctf_fs = ctf_fs;
port_data->ds_file_group = ds_file_group;
ret = bt_self_component_source_add_output_port(self_comp_src, port_name, port_data, NULL);
g_string_free(ds_file_info->path, TRUE);
}
- g_free(ds_file_info);
+ delete ds_file_info;
}
static struct ctf_fs_ds_file_info *ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns)
{
- struct ctf_fs_ds_file_info *ds_file_info;
-
- ds_file_info = g_new0(struct ctf_fs_ds_file_info, 1);
- if (!ds_file_info) {
- goto end;
- }
-
+ 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);
ctf_fs_ds_index_destroy(ds_file_group->index);
bt_stream_put_ref(ds_file_group->stream);
- g_free(ds_file_group);
+ delete ds_file_group;
}
static struct ctf_fs_ds_file_group *ctf_fs_ds_file_group_create(struct ctf_fs_trace *ctf_fs_trace,
uint64_t stream_instance_id,
struct ctf_fs_ds_index *index)
{
- struct ctf_fs_ds_file_group *ds_file_group;
-
- ds_file_group = g_new0(struct ctf_fs_ds_file_group, 1);
- if (!ds_file_group) {
- goto error;
- }
-
+ ctf_fs_ds_file_group *ds_file_group = new ctf_fs_ds_file_group;
ds_file_group->ds_file_infos =
g_ptr_array_new_with_free_func((GDestroyNotify) ctf_fs_ds_file_info_destroy);
if (!ds_file_group->ds_file_infos) {
if (i == index->entries->len || !ds_index_entries_equal(entry, other_entry)) {
array_insert(index->entries, entry, i);
} else {
- g_free(entry);
+ delete entry;
}
}
struct ctf_fs_metadata_config *metadata_config,
bt_logging_level log_level)
{
- struct ctf_fs_trace *ctf_fs_trace;
int ret;
/* Only one of them must be set. */
BT_ASSERT(!self_comp != !self_comp_class);
- ctf_fs_trace = g_new0(struct ctf_fs_trace, 1);
- if (!ctf_fs_trace) {
- goto end;
- }
-
+ ctf_fs_trace *ctf_fs_trace = new struct ctf_fs_trace;
ctf_fs_trace->log_level = log_level;
ctf_fs_trace->self_comp = self_comp;
ctf_fs_trace->self_comp_class = self_comp_class;
goto error;
}
- ctf_fs_trace->metadata = g_new0(struct ctf_fs_metadata, 1);
- if (!ctf_fs_trace->metadata) {
- goto error;
- }
-
+ ctf_fs_trace->metadata = new ctf_fs_metadata;
ctf_fs_metadata_init(ctf_fs_trace->metadata);
ctf_fs_trace->ds_file_groups =
g_ptr_array_new_with_free_func((GDestroyNotify) ctf_fs_ds_file_group_destroy);
struct ctf_fs_file
{
- bt_logging_level log_level;
+ bt_logging_level log_level = (bt_logging_level) 0;
/* Weak */
- bt_self_component *self_comp;
+ bt_self_component *self_comp = nullptr;
/* Owned by this */
- GString *path;
+ GString *path = nullptr;
/* Owned by this */
- FILE *fp;
+ FILE *fp = nullptr;
- off_t size;
+ off_t size = 0;
};
struct ctf_fs_metadata
{
/* Owned by this */
- struct ctf_metadata_decoder *decoder;
+ struct ctf_metadata_decoder *decoder = nullptr;
/* Owned by this */
- bt_trace_class *trace_class;
+ bt_trace_class *trace_class = nullptr;
/* Weak (owned by `decoder` above) */
- struct ctf_trace_class *tc;
+ struct ctf_trace_class *tc = nullptr;
/* Owned by this */
- char *text;
+ char *text = nullptr;
- int bo;
+ int bo = 0;
};
struct ctf_fs_component
{
- bt_logging_level log_level;
+ bt_logging_level log_level = (bt_logging_level) 0;
/* Array of struct ctf_fs_port_data *, owned by this */
- GPtrArray *port_data;
+ GPtrArray *port_data = nullptr;
/* Owned by this */
- struct ctf_fs_trace *trace;
+ struct ctf_fs_trace *trace = nullptr;
struct ctf_fs_metadata_config metadata_config;
};
struct ctf_fs_trace
{
- bt_logging_level log_level;
+ bt_logging_level log_level = (bt_logging_level) 0;
/*
* Weak. These are mostly used to generate log messages or to append
* error causes. They are mutually exclusive, only one of them must be
* set.
*/
- bt_self_component *self_comp;
- bt_self_component_class *self_comp_class;
+ bt_self_component *self_comp = nullptr;
+ bt_self_component_class *self_comp_class = nullptr;
/* Owned by this */
- struct ctf_fs_metadata *metadata;
+ struct ctf_fs_metadata *metadata = nullptr;
/* Owned by this */
- bt_trace *trace;
+ bt_trace *trace = nullptr;
/* Array of struct ctf_fs_ds_file_group *, owned by this */
- GPtrArray *ds_file_groups;
+ GPtrArray *ds_file_groups = nullptr;
/* Owned by this */
- GString *path;
+ GString *path = nullptr;
/* Next automatic stream ID when not provided by packet header */
- uint64_t next_stream_id;
+ uint64_t next_stream_id = 0;
};
struct ctf_fs_ds_index_entry
{
/* Weak, belongs to ctf_fs_ds_file_info. */
- const char *path;
+ const char *path = nullptr;
/* Position, in bytes, of the packet from the beginning of the file. */
- uint64_t offset;
+ uint64_t offset = 0;
/* Size of the packet, in bytes. */
- uint64_t packet_size;
+ uint64_t packet_size = 0;
/*
* Extracted from the packet context, relative to the respective fields'
* mapped clock classes (in cycles).
*/
- uint64_t timestamp_begin, timestamp_end;
+ uint64_t timestamp_begin = 0, timestamp_end = 0;
/*
* Converted from the packet context, relative to the trace's EPOCH
* (in ns since EPOCH).
*/
- int64_t timestamp_begin_ns, timestamp_end_ns;
+ int64_t timestamp_begin_ns = 0, timestamp_end_ns = 0;
/*
* Packet sequence number, or UINT64_MAX if not present in the index.
*/
- uint64_t packet_seq_num;
+ uint64_t packet_seq_num = 0;
};
struct ctf_fs_ds_index
{
/* Array of pointer to struct ctf_fs_ds_index_entry. */
- GPtrArray *entries;
+ GPtrArray *entries = nullptr;
};
struct ctf_fs_ds_file_group
* You can call ctf_fs_ds_file_create() with one of those paths
* and the trace IR stream below.
*/
- GPtrArray *ds_file_infos;
+ GPtrArray *ds_file_infos = nullptr;
/* Owned by this */
- struct ctf_stream_class *sc;
+ struct ctf_stream_class *sc = nullptr;
/* Owned by this */
- bt_stream *stream;
+ bt_stream *stream = nullptr;
/* Stream (instance) ID; -1ULL means none */
- uint64_t stream_id;
+ uint64_t stream_id = 0;
/* Weak, belongs to component */
- struct ctf_fs_trace *ctf_fs_trace;
+ struct ctf_fs_trace *ctf_fs_trace = nullptr;
/*
* Owned by this.
*/
- struct ctf_fs_ds_index *index;
+ struct ctf_fs_ds_index *index = nullptr;
};
struct ctf_fs_port_data
{
/* Weak, belongs to ctf_fs_trace */
- struct ctf_fs_ds_file_group *ds_file_group;
+ struct ctf_fs_ds_file_group *ds_file_group = nullptr;
/* Weak */
- struct ctf_fs_component *ctf_fs;
+ struct ctf_fs_component *ctf_fs = nullptr;
};
struct ctf_fs_msg_iter_data
{
- bt_logging_level log_level;
+ bt_logging_level log_level = (bt_logging_level) 0;
/* Weak */
- bt_self_component *self_comp;
+ bt_self_component *self_comp = nullptr;
/* Weak */
- bt_self_message_iterator *self_msg_iter;
+ bt_self_message_iterator *self_msg_iter = nullptr;
/* Weak, belongs to ctf_fs_trace */
- struct ctf_fs_ds_file_group *ds_file_group;
+ struct ctf_fs_ds_file_group *ds_file_group = nullptr;
/* Owned by this */
- struct ctf_msg_iter *msg_iter;
+ struct ctf_msg_iter *msg_iter = nullptr;
/*
* Saved error. If we hit an error in the _next method, but have some
* messages ready to return, we save the error here and return it on
* the next _next call.
*/
- bt_message_iterator_class_next_method_status next_saved_status;
- const struct bt_error *next_saved_error;
+ bt_message_iterator_class_next_method_status next_saved_status =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
+ const struct bt_error *next_saved_error = nullptr;
- struct ctf_fs_ds_group_medops_data *msg_iter_medops_data;
+ struct ctf_fs_ds_group_medops_data *msg_iter_medops_data = nullptr;
};
bt_component_class_initialize_method_status
struct ctf_fs_file *file = NULL;
bt_logging_level log_level = ctf_fs_trace->log_level;
- ctf_metadata_decoder_config decoder_config {};
- decoder_config.log_level = ctf_fs_trace->log_level, decoder_config.self_comp = self_comp,
- decoder_config.clock_class_offset_s = config ? config->clock_class_offset_s : 0,
- decoder_config.clock_class_offset_ns = config ? config->clock_class_offset_ns : 0,
+ ctf_metadata_decoder_config decoder_config;
+ decoder_config.log_level = ctf_fs_trace->log_level;
+ decoder_config.self_comp = self_comp;
+ decoder_config.clock_class_offset_s = config ? config->clock_class_offset_s : 0;
+ decoder_config.clock_class_offset_ns = config ? config->clock_class_offset_ns : 0;
decoder_config.force_clock_class_origin_unix_epoch =
- config ? config->force_clock_class_origin_unix_epoch : false,
- decoder_config.create_trace_class = true,
+ config ? config->force_clock_class_origin_unix_epoch : false;
+ decoder_config.create_trace_class = true;
file = get_file(ctf_fs_trace->path->str, log_level, self_comp);
if (!file) {
struct ctf_fs_metadata_config
{
- bool force_clock_class_origin_unix_epoch;
- int64_t clock_class_offset_s;
- int64_t clock_class_offset_ns;
+ bool force_clock_class_origin_unix_epoch = false;
+ int64_t clock_class_offset_s = 0;
+ int64_t clock_class_offset_ns = 0;
};
int ctf_fs_metadata_init(struct ctf_fs_metadata *metadata);
const char *path;
bool is_packetized;
struct ctf_metadata_decoder *decoder = NULL;
- ctf_metadata_decoder_config decoder_cfg {};
+ ctf_metadata_decoder_config decoder_cfg;
enum ctf_metadata_decoder_status decoder_status;
GString *g_metadata_text = NULL;
const char *plaintext;
metadata_file = g_fopen(metadata_path, "rb");
if (metadata_file) {
- ctf_metadata_decoder_config metadata_decoder_config {};
enum ctf_metadata_decoder_status decoder_status;
bt_uuid_t uuid;
+ ctf_metadata_decoder_config metadata_decoder_config;
metadata_decoder_config.log_level = log_level;
metadata_decoder_config.self_comp_class =
bt_self_component_class_source_as_self_component_class(comp_class);
lttng_live_stream_iterator_create(struct lttng_live_session *session, uint64_t ctf_trace_id,
uint64_t stream_id, bt_self_message_iterator *self_msg_iter)
{
- struct lttng_live_stream_iterator *stream_iter;
struct lttng_live_component *lttng_live;
struct lttng_live_trace *trace;
bt_logging_level log_level;
lttng_live = session->lttng_live_msg_iter->lttng_live_comp;
- stream_iter = g_new0(struct lttng_live_stream_iterator, 1);
- if (!stream_iter) {
- BT_COMP_LOGE_APPEND_CAUSE(self_comp,
- "Failed to allocate struct lttng_live_stream_iterator");
- goto error;
- }
-
+ lttng_live_stream_iterator *stream_iter = new lttng_live_stream_iterator;
stream_iter->log_level = log_level;
stream_iter->self_comp = self_comp;
trace = lttng_live_session_borrow_or_create_trace_by_id(session, ctf_trace_id);
/* Track the number of active stream iterator. */
stream_iter->trace->session->lttng_live_msg_iter->active_stream_iter--;
- g_free(stream_iter);
+ delete stream_iter;
}
BT_TRACE_CLASS_PUT_REF_AND_RESET(trace->trace_class);
lttng_live_metadata_fini(trace);
- g_free(trace);
+ delete trace;
}
static struct lttng_live_trace *lttng_live_create_trace(struct lttng_live_session *session,
uint64_t trace_id)
{
- struct lttng_live_trace *trace = NULL;
bt_logging_level log_level = session->log_level;
bt_self_component *self_comp = session->self_comp;
BT_COMP_LOGD("Creating live trace: "
"session-id=%" PRIu64 ", trace-id=%" PRIu64,
session->id, trace_id);
- trace = g_new0(struct lttng_live_trace, 1);
- if (!trace) {
- BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to allocate live trace");
- goto error;
- }
+
+ lttng_live_trace *trace = new lttng_live_trace;
trace->log_level = session->log_level;
trace->self_comp = session->self_comp;
trace->session = session;
trace->metadata_stream_state = LTTNG_LIVE_METADATA_STREAM_STATE_NEEDED;
g_ptr_array_add(session->traces, trace);
- goto end;
-error:
- g_free(trace);
- trace = NULL;
-end:
return trace;
}
int lttng_live_add_session(struct lttng_live_msg_iter *lttng_live_msg_iter, uint64_t session_id,
const char *hostname, const char *session_name)
{
- int ret = 0;
- struct lttng_live_session *session;
bt_logging_level log_level = lttng_live_msg_iter->log_level;
bt_self_component *self_comp = lttng_live_msg_iter->self_comp;
"session-id=%" PRIu64 ", hostname=\"%s\" session-name=\"%s\"",
session_id, hostname, session_name);
- session = g_new0(struct lttng_live_session, 1);
- if (!session) {
- BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to allocate live session");
- goto error;
- }
-
+ lttng_live_session *session = new lttng_live_session;
session->log_level = lttng_live_msg_iter->log_level;
session->self_comp = lttng_live_msg_iter->self_comp;
session->id = session_id;
BT_ASSERT(session->session_name);
g_ptr_array_add(lttng_live_msg_iter->sessions, session);
- goto end;
-error:
- g_free(session);
- ret = -1;
-end:
- return ret;
+
+ return 0;
}
static void lttng_live_destroy_session(struct lttng_live_session *session)
if (session->hostname) {
g_string_free(session->hostname, TRUE);
}
+
if (session->session_name) {
g_string_free(session->session_name, TRUE);
}
- g_free(session);
+
+ delete session;
end:
return;
BT_ASSERT(lttng_live_msg_iter->active_stream_iter == 0);
lttng_live_msg_iter->lttng_live_comp->has_msg_iter = false;
- g_free(lttng_live_msg_iter);
+ delete lttng_live_msg_iter;
end:
return;
lttng_live_msg_iter_create(struct lttng_live_component *lttng_live_comp,
bt_self_message_iterator *self_msg_it)
{
- bt_self_component *self_comp = lttng_live_comp->self_comp;
- bt_logging_level log_level = lttng_live_comp->log_level;
-
- struct lttng_live_msg_iter *lttng_live_msg_iter = g_new0(struct lttng_live_msg_iter, 1);
- if (!lttng_live_msg_iter) {
- BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Failed to allocate lttng_live_msg_iter");
- goto end;
- }
-
+ lttng_live_msg_iter *lttng_live_msg_iter = new struct lttng_live_msg_iter;
lttng_live_msg_iter->log_level = lttng_live_comp->log_level;
lttng_live_msg_iter->self_comp = lttng_live_comp->self_comp;
lttng_live_msg_iter->lttng_live_comp = lttng_live_comp;
g_ptr_array_new_with_free_func((GDestroyNotify) lttng_live_destroy_session);
BT_ASSERT(lttng_live_msg_iter->sessions);
-end:
return lttng_live_msg_iter;
}
if (!lttng_live) {
return;
}
+
if (lttng_live->params.url) {
g_string_free(lttng_live->params.url, TRUE);
}
- g_free(lttng_live);
+
+ delete lttng_live;
}
void lttng_live_component_finalize(bt_self_component_source *component)
goto error;
}
- lttng_live = g_new0(struct lttng_live_component, 1);
- if (!lttng_live) {
- status = BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
- goto end;
- }
+ lttng_live = new lttng_live_component;
lttng_live->log_level = log_level;
lttng_live->self_comp = self_comp;
lttng_live->max_query_size = MAX_QUERY_SIZE;
/* Iterator over a live stream. */
struct lttng_live_stream_iterator
{
- bt_logging_level log_level;
- bt_self_component *self_comp;
+ bt_logging_level log_level = (bt_logging_level) 0;
+ bt_self_component *self_comp = nullptr;
/* Owned by this. */
- bt_stream *stream;
+ bt_stream *stream = nullptr;
/* Weak reference. */
- struct lttng_live_trace *trace;
+ struct lttng_live_trace *trace = nullptr;
/*
* Since only a single iterator per viewer connection, we have
* only a single message iterator per stream.
*/
- struct ctf_msg_iter *msg_iter;
+ struct ctf_msg_iter *msg_iter = nullptr;
- uint64_t viewer_stream_id;
+ uint64_t viewer_stream_id = 0;
struct
{
- bool is_set;
- uint64_t value;
+ bool is_set = false;
+ uint64_t value = 0;
} ctf_stream_class_id;
/* base offset in current index. */
- uint64_t base_offset;
+ uint64_t base_offset = 0;
/* len to read in current index. */
- uint64_t len;
+ uint64_t len = 0;
/* offset in current index. */
- uint64_t offset;
+ uint64_t offset = 0;
/*
* Clock Snapshot value of the last message iterator inactivity message
*/
struct
{
- bool is_set;
- uint64_t value;
+ bool is_set = false;
+ uint64_t value = 0;
} last_inactivity_ts;
/*
* Clock Snapshot value of the current message iterator inactivity
* message we might want to send downstream.
*/
- uint64_t current_inactivity_ts;
+ uint64_t current_inactivity_ts = 0;
- enum lttng_live_stream_state state;
+ enum lttng_live_stream_state state = LTTNG_LIVE_STREAM_QUIESCENT;
/*
* The current message produced by this live stream iterator. Owned by
* this.
*/
- const bt_message *current_msg;
+ const bt_message *current_msg = nullptr;
/* Timestamp in nanoseconds of the current message (current_msg). */
- int64_t current_msg_ts_ns;
+ int64_t current_msg_ts_ns = 0;
/* Owned by this. */
- uint8_t *buf;
- size_t buflen;
+ uint8_t *buf = nullptr;
+ size_t buflen = 0;
/* Owned by this. */
- GString *name;
+ GString *name = nullptr;
- bool has_stream_hung_up;
+ bool has_stream_hung_up = false;
};
struct lttng_live_metadata
{
- bt_logging_level log_level;
- bt_self_component *self_comp;
+ bt_logging_level log_level = (bt_logging_level) 0;
+ bt_self_component *self_comp = nullptr;
- uint64_t stream_id;
+ uint64_t stream_id = 0;
/* Weak reference. */
- struct ctf_metadata_decoder *decoder;
+ struct ctf_metadata_decoder *decoder = nullptr;
};
enum lttng_live_metadata_stream_state
struct lttng_live_trace
{
- bt_logging_level log_level;
- bt_self_component *self_comp;
+ bt_logging_level log_level = (bt_logging_level) 0;
+ bt_self_component *self_comp = nullptr;
/* Back reference to session. */
- struct lttng_live_session *session;
+ struct lttng_live_session *session = nullptr;
/* ctf trace ID within the session. */
- uint64_t id;
+ uint64_t id = 0;
/* Owned by this. */
- bt_trace *trace;
+ bt_trace *trace = nullptr;
/* Weak reference. */
- bt_trace_class *trace_class;
+ bt_trace_class *trace_class = nullptr;
- struct lttng_live_metadata *metadata;
+ struct lttng_live_metadata *metadata = nullptr;
- const bt_clock_class *clock_class;
+ const bt_clock_class *clock_class = nullptr;
/* Array of pointers to struct lttng_live_stream_iterator. */
/* Owned by this. */
- GPtrArray *stream_iterators;
+ GPtrArray *stream_iterators = nullptr;
- enum lttng_live_metadata_stream_state metadata_stream_state;
+ enum lttng_live_metadata_stream_state metadata_stream_state =
+ LTTNG_LIVE_METADATA_STREAM_STATE_NEEDED;
};
struct lttng_live_session
{
- bt_logging_level log_level;
- bt_self_component *self_comp;
+ bt_logging_level log_level = (bt_logging_level) 0;
+ bt_self_component *self_comp = nullptr;
/* Weak reference. */
- struct lttng_live_msg_iter *lttng_live_msg_iter;
+ struct lttng_live_msg_iter *lttng_live_msg_iter = nullptr;
/* Owned by this. */
- GString *hostname;
+ GString *hostname = nullptr;
/* Owned by this. */
- GString *session_name;
+ GString *session_name = nullptr;
- uint64_t id;
+ uint64_t id = 0;
/* Array of pointers to struct lttng_live_trace. */
- GPtrArray *traces;
+ GPtrArray *traces = nullptr;
- bool attached;
- bool new_streams_needed;
- bool lazy_stream_msg_init;
- bool closed;
+ bool attached = false;
+ bool new_streams_needed = false;
+ bool lazy_stream_msg_init = false;
+ bool closed = false;
};
enum session_not_found_action
*/
struct lttng_live_component
{
- bt_logging_level log_level;
+ bt_logging_level log_level = (bt_logging_level) 0;
/* Weak reference. */
- bt_self_component *self_comp;
+ bt_self_component *self_comp = nullptr;
struct
{
- GString *url;
- enum session_not_found_action sess_not_found_act;
+ GString *url = nullptr;
+ enum session_not_found_action sess_not_found_act = SESSION_NOT_FOUND_ACTION_CONTINUE;
} params;
- size_t max_query_size;
+ size_t max_query_size = 0;
/*
* Keeps track of whether the downstream component already has a
* message iterator on this component.
*/
- bool has_msg_iter;
+ bool has_msg_iter = false;
};
struct lttng_live_msg_iter
{
- bt_logging_level log_level;
- bt_self_component *self_comp;
+ bt_logging_level log_level = (bt_logging_level) 0;
+ bt_self_component *self_comp = nullptr;
/* Weak reference. */
- struct lttng_live_component *lttng_live_comp;
+ struct lttng_live_component *lttng_live_comp = nullptr;
/* Weak reference. */
- bt_self_message_iterator *self_msg_iter;
+ bt_self_message_iterator *self_msg_iter = nullptr;
/* Owned by this. */
- struct live_viewer_connection *viewer_connection;
+ struct live_viewer_connection *viewer_connection = nullptr;
/* Array of pointers to struct lttng_live_session. */
- GPtrArray *sessions;
+ GPtrArray *sessions = nullptr;
/* Number of live stream iterator this message iterator has.*/
- uint64_t active_stream_iter;
+ uint64_t active_stream_iter = 0;
/* Timestamp in nanosecond of the last message sent downstream. */
- int64_t last_msg_ts_ns;
+ int64_t last_msg_ts_ns = 0;
/* True if the iterator was interrupted. */
- bool was_interrupted;
+ bool was_interrupted = false;
};
enum lttng_live_iterator_status
{
bt_self_component *self_comp = session->self_comp;
bt_logging_level log_level = session->log_level;
- struct lttng_live_metadata *metadata = NULL;
struct lttng_live_trace *trace;
- ctf_metadata_decoder_config cfg {};
+ ctf_metadata_decoder_config cfg;
cfg.log_level = session->log_level;
cfg.self_comp = session->self_comp;
cfg.clock_class_offset_s = 0;
cfg.clock_class_offset_ns = 0;
cfg.create_trace_class = true;
- metadata = g_new0(struct lttng_live_metadata, 1);
- if (!metadata) {
- return -1;
- }
+ lttng_live_metadata *metadata = new lttng_live_metadata;
metadata->log_level = session->log_level;
metadata->self_comp = session->self_comp;
metadata->stream_id = stream_id;
error:
ctf_metadata_decoder_destroy(metadata->decoder);
- g_free(metadata);
+ delete metadata;
return -1;
}
}
ctf_metadata_decoder_destroy(metadata->decoder);
trace->metadata = NULL;
- g_free(metadata);
+ delete metadata;
}
bt_logging_level log_level, const char *url, bool in_query,
struct lttng_live_msg_iter *lttng_live_msg_iter, struct live_viewer_connection **viewer)
{
- struct live_viewer_connection *viewer_connection;
enum lttng_live_viewer_status status;
- viewer_connection = g_new0(struct live_viewer_connection, 1);
+ live_viewer_connection *viewer_connection = new live_viewer_connection;
if (bt_socket_init(log_level) != 0) {
BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
g_string_free(viewer_connection->proto, true);
}
- g_free(viewer_connection);
+ delete viewer_connection;
bt_socket_fini();
struct live_viewer_connection
{
- bt_logging_level log_level;
- bt_self_component *self_comp;
- bt_self_component_class *self_comp_class;
+ bt_logging_level log_level = (bt_logging_level) 0;
+ bt_self_component *self_comp = nullptr;
+ bt_self_component_class *self_comp_class = nullptr;
- GString *url;
+ GString *url = nullptr;
- GString *relay_hostname;
- GString *target_hostname;
- GString *session_name;
- GString *proto;
+ GString *relay_hostname = nullptr;
+ GString *target_hostname = nullptr;
+ GString *session_name = nullptr;
+ GString *proto = nullptr;
- BT_SOCKET control_sock;
- int port;
+ BT_SOCKET control_sock {};
+ int port = 0;
- int32_t major;
- int32_t minor;
+ int32_t major = 0;
+ int32_t minor = 0;
- bool in_query;
- struct lttng_live_msg_iter *lttng_live_msg_iter;
+ bool in_query = false;
+ struct lttng_live_msg_iter *lttng_live_msg_iter = nullptr;
};
struct packet_index_time