-int bt_ctf_field_type_structure_set_field_index(struct bt_ctf_field_type *type,
- struct bt_ctf_field_type *field, int index)
-{
- int ret = 0;
- struct bt_ctf_field_type_structure *structure;
-
- if (!type) {
- BT_LOGW_STR("Invalid parameter: structure field type is NULL.");
- ret = -1;
- goto end;
- }
-
- if (!field) {
- BT_LOGW_STR("Invalid parameter: field's field type is NULL.");
- ret = -1;
- goto end;
- }
-
- if (bt_ctf_field_type_get_type_id(type) != BT_CTF_FIELD_TYPE_ID_STRUCT) {
- BT_LOGW("Invalid parameter: field type is not a structure field type: "
- "addr=%p, ft-id=%s", type,
- bt_ctf_field_type_id_string(type->id));
- ret = -1;
- goto end;
- }
-
- structure = container_of(type, struct bt_ctf_field_type_structure,
- parent);
- if (index < 0 || index >= structure->fields->len) {
- BT_LOGW("Invalid parameter: index is out of bounds: "
- "addr=%p, index=%" PRIu64 ", count=%u",
- type, index, structure->fields->len);
- ret = -1;
- goto end;
- }
-
- bt_get(field);
- bt_put(((struct structure_field *)
- g_ptr_array_index(structure->fields, index))->type);
- ((struct structure_field *) structure->fields->pdata[index])->type =
- field;
-end:
- return ret;
-}
-
-BT_HIDDEN
-int bt_ctf_field_type_variant_get_field_name_index(
- struct bt_ctf_field_type *type, const char *name)