return ds_file_group;
}
+/* Replace by g_ptr_array_insert when we depend on glib >= 2.40. */
+static
+void array_insert(GPtrArray *array, gpointer element, size_t pos)
+{
+ size_t original_array_len = array->len;
+
+ /* Allocate an unused element at the end of the array. */
+ g_ptr_array_add(array, NULL);
+
+ /* If we are not inserting at the end, move the elements by one. */
+ if (pos < original_array_len) {
+ memmove(&(array->pdata[pos + 1]),
+ &(array->pdata[pos]),
+ (original_array_len - pos) * sizeof(gpointer));
+ }
+
+ /* Insert the value and bump the array len */
+ array->pdata[pos] = element;
+}
+
static
int ctf_fs_ds_file_group_add_ds_file_info(
struct ctf_fs_ds_file_group *ds_file_group,
}
}
- if (i == ds_file_group->ds_file_infos->len) {
- /* Append instead */
- i = -1;
- }
-
- g_ptr_array_insert(ds_file_group->ds_file_infos, i, ds_file_info);
+ array_insert(ds_file_group->ds_file_infos, ds_file_info, i);
ds_file_info = NULL;
goto end;
g_string_free(name, TRUE);
- if (!ds_file_group) {
+ if (!ds_file_group->stream) {
BT_LOGE("Cannot create stream for DS file group: "
"addr=%p, stream-name=\"%s\"",
ds_file_group, name->str);
struct ctf_fs_component *ctf_fs;
struct bt_value *value = NULL;
const char *path_param;
- int ret;
+ enum bt_component_status ret;
+ enum bt_value_status value_ret;
ctf_fs = g_new0(struct ctf_fs_component, 1);
if (!ctf_fs) {
}
ret = bt_private_component_set_user_data(priv_comp, ctf_fs);
- assert(ret == 0);
+ assert(ret == BT_COMPONENT_STATUS_OK);
/*
* We don't need to get a new reference here because as long as
goto error;
}
- ret = bt_value_string_get(value, &path_param);
- assert(ret == 0);
+ value_ret = bt_value_string_get(value, &path_param);
+ assert(value_ret == BT_VALUE_STATUS_OK);
BT_PUT(value);
value = bt_value_map_get(params, "clock-class-offset-s");
if (value) {
BT_LOGE("clock-class-offset-s should be an integer");
goto error;
}
- ret = bt_value_integer_get(value,
+ value_ret = bt_value_integer_get(value,
&ctf_fs->metadata_config.clock_class_offset_s);
- assert(ret == 0);
+ assert(value_ret == BT_VALUE_STATUS_OK);
BT_PUT(value);
}
BT_LOGE("clock-class-offset-ns should be an integer");
goto error;
}
- ret = bt_value_integer_get(value,
+ value_ret = bt_value_integer_get(value,
&ctf_fs->metadata_config.clock_class_offset_ns);
- assert(ret == 0);
+ assert(value_ret == BT_VALUE_STATUS_OK);
BT_PUT(value);
}
goto error;
}
- ret = create_ctf_fs_traces(ctf_fs, path_param);
- if (ret) {
+ if (create_ctf_fs_traces(ctf_fs, path_param)) {
goto error;
}
ctf_fs_destroy(ctf_fs);
ctf_fs = NULL;
ret = bt_private_component_set_user_data(priv_comp, NULL);
- assert(ret == 0);
+ assert(ret == BT_COMPONENT_STATUS_OK);
end:
bt_put(value);