for (i = 0; i < field_count; ++i) {
const char *field_name;
- ret = bt_field_type_common_structure_get_field_by_index(ft,
+ ret = bt_field_type_common_structure_borrow_field_by_index(ft,
&field_name, &child_ft, i);
BT_ASSERT(ret == 0);
ret = bt_field_type_common_validate(child_ft);
ft, child_ft, field_name, i);
goto end;
}
-
- BT_PUT(child_ft);
}
end:
- BT_PUT(child_ft);
return ret;
}
for (i = 0; i < field_count; ++i) {
const char *field_name;
- ret = bt_field_type_common_variant_get_field_by_index(ft,
+ ret = bt_field_type_common_variant_borrow_field_by_index(ft,
&field_name, &child_ft, i);
BT_ASSERT(ret == 0);
ret = bt_field_type_common_validate(child_ft);
field_name, i);
goto end;
}
-
- BT_PUT(child_ft);
}
end:
- BT_PUT(child_ft);
return ret;
}
}
BT_HIDDEN
-struct bt_clock_class *bt_field_type_common_integer_get_mapped_clock_class(
+struct bt_clock_class *bt_field_type_common_integer_borrow_mapped_clock_class(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
"Field type");
- return bt_get(int_ft->mapped_clock_class);
+ return int_ft->mapped_clock_class;
}
-struct bt_clock_class *bt_field_type_integer_get_mapped_clock_class(
+struct bt_clock_class *bt_field_type_integer_borrow_mapped_clock_class(
struct bt_field_type *ft)
{
- return bt_field_type_common_integer_get_mapped_clock_class((void *) ft);
+ return bt_field_type_common_integer_borrow_mapped_clock_class(
+ (void *) ft);
}
BT_HIDDEN
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_enumeration_get_container_field_type(
+struct bt_field_type_common *
+bt_field_type_common_enumeration_borrow_container_field_type(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
- return bt_get(enum_ft->container_ft);
+ return BT_TO_COMMON(enum_ft->container_ft);
}
-struct bt_field_type *bt_field_type_enumeration_get_container_field_type(
+struct bt_field_type *bt_field_type_enumeration_borrow_container_field_type(
struct bt_field_type *ft)
{
- return (void *) bt_field_type_common_enumeration_get_container_field_type(
+ return (void *) bt_field_type_common_enumeration_borrow_container_field_type(
(void *) ft);
}
}
BT_HIDDEN
-int bt_field_type_common_structure_get_field_by_index(
+int bt_field_type_common_structure_borrow_field_by_index(
struct bt_field_type_common *ft,
const char **field_name,
struct bt_field_type_common **field_type, uint64_t index)
if (field_type) {
*field_type = field->type;
- bt_get(field->type);
}
if (field_name) {
return 0;
}
-int bt_field_type_structure_get_field_by_index(
+int bt_field_type_structure_borrow_field_by_index(
struct bt_field_type *ft,
const char **field_name,
struct bt_field_type **field_type, uint64_t index)
{
- return bt_field_type_common_structure_get_field_by_index(
+ return bt_field_type_common_structure_borrow_field_by_index(
(void *) ft, field_name, (void *) field_type, index);
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_structure_get_field_type_by_name(
+struct bt_field_type_common *
+bt_field_type_common_structure_borrow_field_type_by_name(
struct bt_field_type_common *ft, const char *name)
{
size_t index;
field = struct_ft->fields->pdata[index];
field_type = field->type;
- bt_get(field_type);
end:
return field_type;
}
-struct bt_field_type *bt_field_type_structure_get_field_type_by_name(
+struct bt_field_type *bt_field_type_structure_borrow_field_type_by_name(
struct bt_field_type *ft, const char *name)
{
- return (void *) bt_field_type_common_structure_get_field_type_by_name(
+ return (void *) bt_field_type_common_structure_borrow_field_type_by_name(
(void *) ft, name);
}
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_tag_field_type(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_tag_field_type(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
goto end;
}
- tag_ft = bt_get(var_ft->tag_ft);
+ tag_ft = BT_TO_COMMON(var_ft->tag_ft);
end:
return tag_ft;
}
-struct bt_field_type *bt_field_type_variant_get_tag_field_type(
+struct bt_field_type *bt_field_type_variant_borrow_tag_field_type(
struct bt_field_type *ft)
{
- return (void *) bt_field_type_common_variant_get_tag_field_type(
+ return (void *) bt_field_type_common_variant_borrow_tag_field_type(
(void *) ft);
}
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_by_name(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_by_name(
struct bt_field_type_common *ft,
const char *field_name)
{
field = g_ptr_array_index(var_ft->fields, index);
field_type = field->type;
- bt_get(field_type);
end:
return field_type;
}
-struct bt_field_type *bt_field_type_variant_get_field_type_by_name(
+struct bt_field_type *bt_field_type_variant_borrow_field_type_by_name(
struct bt_field_type *ft,
const char *field_name)
{
- return (void *) bt_field_type_common_variant_get_field_type_by_name(
+ return (void *) bt_field_type_common_variant_borrow_field_type_by_name(
(void *) ft, field_name);
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_from_tag(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_from_tag(
struct bt_field_type_common *ft,
struct bt_field_common *tag_field,
bt_field_common_create_func field_create_func)
goto end;
}
- field_type = bt_field_type_common_variant_get_field_type_by_name(
+ field_type = bt_field_type_common_variant_borrow_field_type_by_name(
ft, enum_value);
end:
return field_type;
}
-struct bt_field_type *bt_field_type_variant_get_field_type_from_tag(
+struct bt_field_type *bt_field_type_variant_borrow_field_type_from_tag(
struct bt_field_type *ft,
struct bt_field *tag_field)
{
- return (void *) bt_field_type_common_variant_get_field_type_from_tag(
+ return (void *) bt_field_type_common_variant_borrow_field_type_from_tag(
(void *) ft, (void *) tag_field,
(bt_field_common_create_func) bt_field_create);
}
}
BT_HIDDEN
-int bt_field_type_common_variant_get_field_by_index(
+int bt_field_type_common_variant_borrow_field_by_index(
struct bt_field_type_common *ft,
const char **field_name,
struct bt_field_type_common **field_type, uint64_t index)
if (field_type) {
*field_type = field->type;
- bt_get(field->type);
}
if (field_name) {
return 0;
}
-int bt_field_type_variant_get_field_by_index(struct bt_field_type *ft,
+int bt_field_type_variant_borrow_field_by_index(struct bt_field_type *ft,
const char **field_name, struct bt_field_type **field_type,
uint64_t index)
{
- return bt_field_type_common_variant_get_field_by_index((void *) ft,
+ return bt_field_type_common_variant_borrow_field_by_index((void *) ft,
field_name, (void *) field_type, index);
}
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_array_get_element_field_type(
+struct bt_field_type_common *
+bt_field_type_common_array_borrow_element_field_type(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ARRAY,
"Field type");
BT_ASSERT(array_ft && array_ft->element_ft);
- return bt_get(array_ft->element_ft);
+ return array_ft->element_ft;
}
-struct bt_field_type *bt_field_type_array_get_element_field_type(
+struct bt_field_type *bt_field_type_array_borrow_element_field_type(
struct bt_field_type *ft)
{
- return (void *) bt_field_type_common_array_get_element_field_type(
+ return (void *) bt_field_type_common_array_borrow_element_field_type(
(void *) ft);
}
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_sequence_get_element_field_type(
+struct bt_field_type_common *bt_field_type_common_sequence_borrow_element_field_type(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
"Field type");
- return bt_get(seq_ft->element_ft);
+ return seq_ft->element_ft;
}
-struct bt_field_type *bt_field_type_sequence_get_element_field_type(
+struct bt_field_type *bt_field_type_sequence_borrow_element_field_type(
struct bt_field_type *ft)
{
- return (void *) bt_field_type_common_sequence_get_element_field_type(
+ return (void *) bt_field_type_common_sequence_borrow_element_field_type(
(void *) ft);
}
case BT_FIELD_TYPE_ID_SEQUENCE:
{
struct bt_field_type_common *element_ft =
- bt_field_type_common_sequence_get_element_field_type(ft);
+ bt_field_type_common_sequence_borrow_element_field_type(ft);
BT_ASSERT(element_ft);
ret = bt_field_type_common_get_alignment(element_ft);
- bt_put(element_ft);
break;
}
case BT_FIELD_TYPE_ID_ARRAY:
{
struct bt_field_type_common *element_ft =
- bt_field_type_common_array_get_element_field_type(ft);
+ bt_field_type_common_array_borrow_element_field_type(ft);
BT_ASSERT(element_ft);
ret = bt_field_type_common_get_alignment(element_ft);
- bt_put(element_ft);
break;
}
case BT_FIELD_TYPE_ID_STRUCT:
struct bt_field_type_common *field = NULL;
int field_alignment;
- ret = bt_field_type_common_structure_get_field_by_index(
+ ret = bt_field_type_common_structure_borrow_field_by_index(
ft, NULL, &field, i);
BT_ASSERT(ret == 0);
BT_ASSERT(field);
field_alignment = bt_field_type_common_get_alignment(
field);
- bt_put(field);
if (field_alignment < 0) {
ret = field_alignment;
goto end;
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_signed(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_signed(
struct bt_field_type_common_variant *var_ft,
int64_t tag_value)
{
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_variant_get_field_type_unsigned(
+struct bt_field_type_common *
+bt_field_type_common_variant_borrow_field_type_unsigned(
struct bt_field_type_common_variant *var_ft,
uint64_t tag_value)
{
}
BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_get_field_at_index(
+struct bt_field_type_common *bt_field_type_common_borrow_field_at_index(
struct bt_field_type_common *ft, int index)
{
struct bt_field_type_common *field_type = NULL;
switch (ft->id) {
case BT_FIELD_TYPE_ID_STRUCT:
{
- int ret = bt_field_type_common_structure_get_field_by_index(
+ int ret = bt_field_type_common_structure_borrow_field_by_index(
ft, NULL, &field_type, index);
if (ret) {
field_type = NULL;
}
case BT_FIELD_TYPE_ID_VARIANT:
{
- int ret = bt_field_type_common_variant_get_field_by_index(
+ int ret = bt_field_type_common_variant_borrow_field_by_index(
ft, NULL, &field_type, index);
if (ret) {
field_type = NULL;
break;
}
case BT_FIELD_TYPE_ID_ARRAY:
- field_type = bt_field_type_common_array_get_element_field_type(ft);
+ field_type =
+ bt_field_type_common_array_borrow_element_field_type(ft);
break;
case BT_FIELD_TYPE_ID_SEQUENCE:
- field_type = bt_field_type_common_sequence_get_element_field_type(ft);
+ field_type =
+ bt_field_type_common_sequence_borrow_element_field_type(ft);
break;
default:
break;
}
BT_HIDDEN
-struct bt_field_path *bt_field_type_common_variant_get_tag_field_path(
+struct bt_field_path *bt_field_type_common_variant_borrow_tag_field_path(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
"Field type");
- return bt_get(var_ft->tag_field_path);
+ return var_ft->tag_field_path;
}
-struct bt_field_path *bt_field_type_variant_get_tag_field_path(
+struct bt_field_path *bt_field_type_variant_borrow_tag_field_path(
struct bt_field_type *ft)
{
- return bt_field_type_common_variant_get_tag_field_path((void *) ft);
+ return bt_field_type_common_variant_borrow_tag_field_path((void *) ft);
}
BT_HIDDEN
-struct bt_field_path *bt_field_type_common_sequence_get_length_field_path(
+struct bt_field_path *bt_field_type_common_sequence_borrow_length_field_path(
struct bt_field_type_common *ft)
{
struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
BT_ASSERT_PRE_NON_NULL(ft, "Field type");
BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
"Field type");
- return bt_get(seq_ft->length_field_path);
+ return seq_ft->length_field_path;
}
-struct bt_field_path *bt_field_type_sequence_get_length_field_path(
+struct bt_field_path *bt_field_type_sequence_borrow_length_field_path(
struct bt_field_type *ft)
{
- return bt_field_type_common_sequence_get_length_field_path((void *) ft);
+ return bt_field_type_common_sequence_borrow_length_field_path(
+ (void *) ft);
}
BT_HIDDEN
case BT_FIELD_TYPE_ID_INTEGER:
{
struct bt_clock_class *mapped_clock_class =
- bt_field_type_common_integer_get_mapped_clock_class(ft);
+ bt_field_type_common_integer_borrow_mapped_clock_class(ft);
if (!mapped_clock_class) {
goto end;
if (!*expected_clock_class) {
/* Move reference to output parameter */
- *expected_clock_class = mapped_clock_class;
+ *expected_clock_class = bt_get(mapped_clock_class);
mapped_clock_class = NULL;
BT_LOGV("Setting expected clock class: "
"expected-clock-class-addr=%p",
}
}
- bt_put(mapped_clock_class);
break;
}
case BT_FIELD_TYPE_ID_ENUM:
switch (ft->id) {
case BT_FIELD_TYPE_ID_ENUM:
- sub_ft = bt_field_type_common_enumeration_get_container_field_type(
+ sub_ft = bt_field_type_common_enumeration_borrow_container_field_type(
ft);
break;
case BT_FIELD_TYPE_ID_ARRAY:
- sub_ft = bt_field_type_common_array_get_element_field_type(
+ sub_ft = bt_field_type_common_array_borrow_element_field_type(
ft);
break;
case BT_FIELD_TYPE_ID_SEQUENCE:
- sub_ft = bt_field_type_common_sequence_get_element_field_type(
+ sub_ft = bt_field_type_common_sequence_borrow_element_field_type(
ft);
break;
default:
BT_ASSERT(sub_ft);
ret = bt_field_type_common_validate_single_clock_class(sub_ft,
expected_clock_class);
- bt_put(sub_ft);
break;
}
case BT_FIELD_TYPE_ID_STRUCT:
const char *name;
struct bt_field_type_common *member_type;
- ret = bt_field_type_common_structure_get_field_by_index(
+ ret = bt_field_type_common_structure_borrow_field_by_index(
ft, &name, &member_type, i);
BT_ASSERT(ret == 0);
ret = bt_field_type_common_validate_single_clock_class(
member_type, expected_clock_class);
- bt_put(member_type);
if (ret) {
BT_LOGW("Structure field type's field's type "
"is not recursively mapped to the "
const char *name;
struct bt_field_type_common *member_type;
- ret = bt_field_type_common_variant_get_field_by_index(
+ ret = bt_field_type_common_variant_borrow_field_by_index(
ft, &name, &member_type, i);
BT_ASSERT(ret == 0);
ret = bt_field_type_common_validate_single_clock_class(
member_type, expected_clock_class);
- bt_put(member_type);
if (ret) {
BT_LOGW("Variant field type's field's type "
"is not recursively mapped to the "