*/
#define BT_LOG_TAG "CTF-WRITER-FIELDS"
-#include <babeltrace/lib-logging-internal.h>
-
-#include <babeltrace/assert-pre-internal.h>
-#include <babeltrace/align-internal.h>
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/compat/fcntl-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ctf-writer/field-types-internal.h>
-#include <babeltrace/ctf-writer/fields-internal.h>
-#include <babeltrace/ctf-writer/serialize-internal.h>
-#include <babeltrace/endian-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace2/lib-logging-internal.h>
+
+#include <babeltrace2/assert-pre-internal.h>
+#include <babeltrace2/align-internal.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/compat/fcntl-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/ctf-writer/field-types-internal.h>
+#include <babeltrace2/ctf-writer/fields-internal.h>
+#include <babeltrace2/endian-internal.h>
+#include <babeltrace2/ctf-writer/object-internal.h>
+#include <babeltrace2/ctf-writer/object.h>
+#include <babeltrace2/ctfser-internal.h>
#include <float.h>
#include <inttypes.h>
#include <inttypes.h>
BT_HIDDEN
int bt_ctf_field_common_structure_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
bt_ctf_field_common_create_func field_create_func,
GDestroyNotify field_release_func)
BT_HIDDEN
int bt_ctf_field_common_variant_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
bt_ctf_field_common_create_func field_create_func,
GDestroyNotify field_release_func)
BT_HIDDEN
int bt_ctf_field_common_string_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods)
{
int ret = 0;
BT_HIDDEN
int bt_ctf_field_common_array_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
bt_ctf_field_common_create_func field_create_func,
GDestroyNotify field_destroy_func)
BT_HIDDEN
int bt_ctf_field_common_sequence_initialize(struct bt_ctf_field_common *field,
struct bt_ctf_field_type_common *type,
- bool is_shared, bt_object_release_func release_func,
+ bool is_shared, bt_ctf_object_release_func release_func,
struct bt_ctf_field_common_methods *methods,
GDestroyNotify field_destroy_func)
{
};
typedef int (*bt_ctf_field_serialize_recursive_func)(
- struct bt_ctf_field_common *, struct bt_ctf_stream_pos *,
+ struct bt_ctf_field_common *, struct bt_ctfser *,
enum bt_ctf_byte_order);
static
BT_LOGD("Destroying CTF writer enumeration field object: addr=%p",
field);
BT_LOGD_STR("Putting container field.");
- bt_put(enumeration->container);
+ bt_ctf_object_put_ref(enumeration->container);
bt_ctf_field_common_finalize((void *) field);
g_free(field);
}
BT_LOGD("Destroying CTF writer variant field object: addr=%p", field);
BT_LOGD_STR("Putting tag field.");
- bt_put(variant->tag);
+ bt_ctf_object_put_ref(variant->tag);
bt_ctf_field_common_variant_finalize_recursive((void *) field);
g_free(field);
}
BT_HIDDEN
int bt_ctf_field_serialize_recursive(struct bt_ctf_field *field,
- struct bt_ctf_stream_pos *pos,
+ struct bt_ctfser *ctfser,
enum bt_ctf_byte_order native_byte_order)
{
struct bt_ctf_field_common *field_common = (void *) field;
bt_ctf_field_serialize_recursive_func serialize_func;
- BT_ASSERT(pos);
+ BT_ASSERT(ctfser);
BT_ASSERT_PRE_NON_NULL(field, "Field");
BT_ASSERT(field_common->spec.writer.serialize_func);
serialize_func = field_common->spec.writer.serialize_func;
- return serialize_func(field_common, pos,
+ return serialize_func(field_common, ctfser,
native_byte_order);
}
static
-int increase_packet_size(struct bt_ctf_stream_pos *pos)
+int bt_ctf_field_integer_serialize(struct bt_ctf_field_common *field,
+ struct bt_ctfser *ctfser,
+ enum bt_ctf_byte_order native_byte_order)
{
int ret;
+ struct bt_ctf_field_type_common_integer *int_type =
+ BT_CTF_FROM_COMMON(field->type);
+ struct bt_ctf_field_common_integer *int_field =
+ BT_CTF_FROM_COMMON(field);
+ enum bt_ctf_byte_order byte_order;
- BT_ASSERT(pos);
- BT_LOGV("Increasing packet size: pos-offset=%" PRId64 ", "
- "cur-packet-size=%" PRIu64,
- pos->offset, pos->packet_size);
- ret = munmap_align(pos->base_mma);
- if (ret) {
- BT_LOGE_ERRNO("Failed to perform an aligned memory unmapping",
- ": ret=%d", ret);
- goto end;
- }
-
- pos->packet_size += PACKET_LEN_INCREMENT;
- do {
- ret = bt_posix_fallocate(pos->fd, pos->mmap_offset,
- pos->packet_size / CHAR_BIT);
- } while (ret == EINTR);
- if (ret) {
- BT_LOGE_ERRNO("Failed to preallocate memory space",
- ": ret=%d", ret);
- errno = EINTR;
- ret = -1;
- goto end;
+ BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Integer field");
+ BT_LOGV("Serializing CTF writer integer field: addr=%p, native-bo=%s",
+ field,
+ bt_ctf_byte_order_string(native_byte_order));
+ byte_order = int_type->user_byte_order;
+ if (byte_order == BT_CTF_BYTE_ORDER_NATIVE) {
+ byte_order = native_byte_order;
}
- pos->base_mma = mmap_align(pos->packet_size / CHAR_BIT, pos->prot,
- pos->flags, pos->fd, pos->mmap_offset);
- if (pos->base_mma == MAP_FAILED) {
- BT_LOGE_ERRNO("Failed to perform an aligned memory mapping",
- ": ret=%d", ret);
- ret = -1;
+ if (int_type->is_signed) {
+ ret = bt_ctfser_write_signed_int(ctfser,
+ int_field->payload.signd, int_type->common.alignment,
+ int_type->size,
+ byte_order == BT_CTF_BYTE_ORDER_LITTLE_ENDIAN ?
+ LITTLE_ENDIAN : BIG_ENDIAN);
+ } else {
+ ret = bt_ctfser_write_unsigned_int(ctfser,
+ int_field->payload.unsignd, int_type->common.alignment,
+ int_type->size,
+ byte_order == BT_CTF_BYTE_ORDER_LITTLE_ENDIAN ?
+ LITTLE_ENDIAN : BIG_ENDIAN);
}
- BT_LOGV("Increased packet size: pos-offset=%" PRId64 ", "
- "new-packet-size=%" PRIu64,
- pos->offset, pos->packet_size);
- BT_ASSERT(pos->packet_size % 8 == 0);
-
-end:
- return ret;
-}
-
-static
-int bt_ctf_field_integer_serialize(struct bt_ctf_field_common *field,
- struct bt_ctf_stream_pos *pos,
- enum bt_ctf_byte_order native_byte_order)
-{
- int ret = 0;
-
- BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Integer field");
- BT_LOGV("Serializing CTF writer integer field: addr=%p, pos-offset=%" PRId64 ", "
- "native-bo=%s", field, pos->offset,
- bt_ctf_byte_order_string((int) native_byte_order));
-
-retry:
- ret = bt_ctf_field_integer_write(field, pos, native_byte_order);
- if (ret == -EFAULT) {
- /*
- * The field is too large to fit in the current packet's
- * remaining space. Bump the packet size and retry.
- */
- ret = increase_packet_size(pos);
- if (ret) {
- BT_LOGE("Cannot increase packet size: ret=%d", ret);
- goto end;
- }
- goto retry;
+ if (unlikely(ret)) {
+ BT_LOGE("Cannot serialize integer field: ret=%d", ret);
+ goto end;
}
end:
}
static
-int bt_ctf_field_enumeration_serialize_recursive(struct bt_ctf_field_common *field,
- struct bt_ctf_stream_pos *pos,
+int bt_ctf_field_enumeration_serialize_recursive(
+ struct bt_ctf_field_common *field, struct bt_ctfser *ctfser,
enum bt_ctf_byte_order native_byte_order)
{
struct bt_ctf_field_enumeration *enumeration = (void *) field;
- BT_LOGV("Serializing enumeration field: addr=%p, pos-offset=%" PRId64 ", "
- "native-bo=%s", field, pos->offset,
- bt_ctf_byte_order_string((int) native_byte_order));
+ BT_LOGV("Serializing enumeration field: addr=%p, native-bo=%s",
+ field, bt_ctf_byte_order_string(native_byte_order));
BT_LOGV_STR("Serializing enumeration field's payload field.");
return bt_ctf_field_serialize_recursive(
- (void *) enumeration->container, pos, native_byte_order);
+ (void *) enumeration->container, ctfser, native_byte_order);
}
static
int bt_ctf_field_floating_point_serialize(struct bt_ctf_field_common *field,
- struct bt_ctf_stream_pos *pos,
+ struct bt_ctfser *ctfser,
enum bt_ctf_byte_order native_byte_order)
{
- int ret = 0;
+ int ret = -1;
+ struct bt_ctf_field_type_common_floating_point *flt_type =
+ BT_CTF_FROM_COMMON(field->type);
+ struct bt_ctf_field_common_floating_point *flt_field = BT_CTF_FROM_COMMON(field);
+ enum bt_ctf_byte_order byte_order;
BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "Floating point number field");
- BT_LOGV("Serializing floating point number field: addr=%p, pos-offset=%" PRId64 ", "
- "native-bo=%s", field, pos->offset,
- bt_ctf_byte_order_string((int) native_byte_order));
+ BT_LOGV("Serializing floating point number field: "
+ "addr=%p, native-bo=%s", field,
+ bt_ctf_byte_order_string(native_byte_order));
-retry:
- ret = bt_ctf_field_floating_point_write(field, pos,
- native_byte_order);
- if (ret == -EFAULT) {
- /*
- * The field is too large to fit in the current packet's
- * remaining space. Bump the packet size and retry.
- */
- ret = increase_packet_size(pos);
- if (ret) {
- BT_LOGE("Cannot increase packet size: ret=%d", ret);
- goto end;
- }
- goto retry;
+ byte_order = flt_type->user_byte_order;
+ if (byte_order == BT_CTF_BYTE_ORDER_NATIVE) {
+ byte_order = native_byte_order;
+ }
+
+ if (flt_type->mant_dig == FLT_MANT_DIG) {
+ ret = bt_ctfser_write_float32(ctfser, flt_field->payload,
+ flt_type->common.alignment,
+ byte_order == BT_CTF_BYTE_ORDER_LITTLE_ENDIAN ?
+ LITTLE_ENDIAN : BIG_ENDIAN);
+ } else if (flt_type->mant_dig == DBL_MANT_DIG) {
+ ret = bt_ctfser_write_float64(ctfser, flt_field->payload,
+ flt_type->common.alignment,
+ byte_order == BT_CTF_BYTE_ORDER_LITTLE_ENDIAN ?
+ LITTLE_ENDIAN : BIG_ENDIAN);
+ } else {
+ abort();
+ }
+
+ if (unlikely(ret)) {
+ BT_LOGE("Cannot serialize floating point number field: "
+ "ret=%d", ret);
+ goto end;
}
end:
static
int bt_ctf_field_structure_serialize_recursive(struct bt_ctf_field_common *field,
- struct bt_ctf_stream_pos *pos,
+ struct bt_ctfser *ctfser,
enum bt_ctf_byte_order native_byte_order)
{
int64_t i;
- int ret = 0;
+ int ret;
struct bt_ctf_field_common_structure *structure = BT_CTF_FROM_COMMON(field);
- BT_LOGV("Serializing structure field: addr=%p, pos-offset=%" PRId64 ", "
- "native-bo=%s", field, pos->offset,
- bt_ctf_byte_order_string((int) native_byte_order));
-
- while (!bt_ctf_stream_pos_access_ok(pos,
- offset_align(pos->offset, field->type->alignment))) {
- ret = increase_packet_size(pos);
- if (ret) {
- BT_LOGE("Cannot increase packet size: ret=%d", ret);
- goto end;
- }
- }
-
- if (!bt_ctf_stream_pos_align(pos, field->type->alignment)) {
- BT_LOGE("Cannot align packet's position: pos-offset=%" PRId64 ", "
- "align=%u", pos->offset, field->type->alignment);
- ret = -1;
+ BT_LOGV("Serializing structure field: addr=%p, native-bo=%s",
+ field, bt_ctf_byte_order_string(native_byte_order));
+ ret = bt_ctfser_align_offset_in_current_packet(ctfser,
+ field->type->alignment);
+ if (unlikely(ret)) {
+ BT_LOGE("Cannot align offset before serializing structure field: "
+ "ret=%d", ret);
goto end;
}
structure->fields, i);
const char *field_name = NULL;
- BT_LOGV("Serializing structure field's field: pos-offset=%" PRId64 ", "
- "field-addr=%p, index=%" PRId64,
- pos->offset, member, i);
+ BT_LOGV("Serializing structure field's field: ser-offset=%" PRIu64 ", "
+ "field-addr=%p, index=%" PRIu64,
+ bt_ctfser_get_offset_in_current_packet_bits(ctfser),
+ member, i);
- if (!member) {
+ if (unlikely(!member)) {
ret = bt_ctf_field_type_common_structure_borrow_field_by_index(
field->type, &field_name, NULL, i);
BT_ASSERT(ret == 0);
goto end;
}
- ret = bt_ctf_field_serialize_recursive((void *) member, pos,
+ ret = bt_ctf_field_serialize_recursive((void *) member, ctfser,
native_byte_order);
- if (ret) {
+ if (unlikely(ret)) {
ret = bt_ctf_field_type_common_structure_borrow_field_by_index(
field->type, &field_name, NULL, i);
BT_ASSERT(ret == 0);
static
int bt_ctf_field_variant_serialize_recursive(struct bt_ctf_field_common *field,
- struct bt_ctf_stream_pos *pos,
+ struct bt_ctfser *ctfser,
enum bt_ctf_byte_order native_byte_order)
{
struct bt_ctf_field_common_variant *variant = BT_CTF_FROM_COMMON(field);
- BT_LOGV("Serializing variant field: addr=%p, pos-offset=%" PRId64 ", "
- "native-bo=%s", field, pos->offset,
- bt_ctf_byte_order_string((int) native_byte_order));
+ BT_LOGV("Serializing variant field: addr=%p, native-bo=%s",
+ field, bt_ctf_byte_order_string(native_byte_order));
BT_LOGV_STR("Serializing variant field's payload field.");
return bt_ctf_field_serialize_recursive(
- (void *) variant->current_field, pos, native_byte_order);
+ (void *) variant->current_field, ctfser, native_byte_order);
}
static
int bt_ctf_field_array_serialize_recursive(struct bt_ctf_field_common *field,
- struct bt_ctf_stream_pos *pos,
+ struct bt_ctfser *ctfser,
enum bt_ctf_byte_order native_byte_order)
{
int64_t i;
int ret = 0;
struct bt_ctf_field_common_array *array = BT_CTF_FROM_COMMON(field);
- BT_LOGV("Serializing array field: addr=%p, pos-offset=%" PRId64 ", "
- "native-bo=%s", field, pos->offset,
- bt_ctf_byte_order_string((int) native_byte_order));
+ BT_LOGV("Serializing array field: addr=%p, native-bo=%s",
+ field, bt_ctf_byte_order_string(native_byte_order));
for (i = 0; i < array->elements->len; i++) {
struct bt_ctf_field_common *elem_field =
g_ptr_array_index(array->elements, i);
BT_LOGV("Serializing array field's element field: "
- "pos-offset=%" PRId64 ", field-addr=%p, index=%" PRId64,
- pos->offset, elem_field, i);
+ "ser-offset=%" PRIu64 ", field-addr=%p, index=%" PRId64,
+ bt_ctfser_get_offset_in_current_packet_bits(ctfser),
+ elem_field, i);
ret = bt_ctf_field_serialize_recursive(
- (void *) elem_field, pos, native_byte_order);
- if (ret) {
+ (void *) elem_field, ctfser, native_byte_order);
+ if (unlikely(ret)) {
BT_LOGW("Cannot serialize array field's element field: "
"array-field-addr=%p, field-addr=%p, "
"index=%" PRId64, field, elem_field, i);
static
int bt_ctf_field_sequence_serialize_recursive(struct bt_ctf_field_common *field,
- struct bt_ctf_stream_pos *pos,
+ struct bt_ctfser *ctfser,
enum bt_ctf_byte_order native_byte_order)
{
int64_t i;
int ret = 0;
struct bt_ctf_field_common_sequence *sequence = BT_CTF_FROM_COMMON(field);
- BT_LOGV("Serializing sequence field: addr=%p, pos-offset=%" PRId64 ", "
- "native-bo=%s", field, pos->offset,
- bt_ctf_byte_order_string((int) native_byte_order));
+ BT_LOGV("Serializing sequence field: addr=%p, native-bo=%s",
+ field, bt_ctf_byte_order_string(native_byte_order));
for (i = 0; i < sequence->elements->len; i++) {
struct bt_ctf_field_common *elem_field =
g_ptr_array_index(sequence->elements, i);
BT_LOGV("Serializing sequence field's element field: "
- "pos-offset=%" PRId64 ", field-addr=%p, index=%" PRId64,
- pos->offset, elem_field, i);
+ "ser-offset=%" PRIu64 ", field-addr=%p, index=%" PRId64,
+ bt_ctfser_get_offset_in_current_packet_bits(ctfser),
+ elem_field, i);
ret = bt_ctf_field_serialize_recursive(
- (void *) elem_field, pos, native_byte_order);
- if (ret) {
+ (void *) elem_field, ctfser, native_byte_order);
+ if (unlikely(ret)) {
BT_LOGW("Cannot serialize sequence field's element field: "
"sequence-field-addr=%p, field-addr=%p, "
"index=%" PRId64, field, elem_field, i);
static
int bt_ctf_field_string_serialize(struct bt_ctf_field_common *field,
- struct bt_ctf_stream_pos *pos,
+ struct bt_ctfser *ctfser,
enum bt_ctf_byte_order native_byte_order)
{
- int64_t i;
- int ret = 0;
+ int ret;
struct bt_ctf_field_common_string *string = BT_CTF_FROM_COMMON(field);
- struct bt_ctf_field_type *character_type =
- get_field_type(FIELD_TYPE_ALIAS_UINT8_T);
- struct bt_ctf_field *character;
BT_ASSERT_PRE_CTF_FIELD_COMMON_IS_SET(field, "String field");
- BT_LOGV("Serializing string field: addr=%p, pos-offset=%" PRId64 ", "
- "native-bo=%s", field, pos->offset,
- bt_ctf_byte_order_string((int) native_byte_order));
-
- BT_LOGV_STR("Creating character field from string field's character field type.");
- character = bt_ctf_field_create(character_type);
-
- for (i = 0; i < string->size + 1; i++) {
- const uint64_t chr = (uint64_t) ((char *) string->buf->data)[i];
-
- ret = bt_ctf_field_integer_unsigned_set_value(character, chr);
- BT_ASSERT(ret == 0);
- BT_LOGV("Serializing string field's character field: "
- "pos-offset=%" PRId64 ", field-addr=%p, "
- "index=%" PRId64 ", char-int=%" PRIu64,
- pos->offset, character, i, chr);
- ret = bt_ctf_field_integer_serialize(
- (void *) character, pos, native_byte_order);
- if (ret) {
- BT_LOGW_STR("Cannot serialize character field.");
- goto end;
- }
+ BT_LOGV("Serializing string field: addr=%p, native-bo=%s",
+ field, bt_ctf_byte_order_string((int) native_byte_order));
+ ret = bt_ctfser_write_string(ctfser, (const char *) string->buf->data);
+ if (unlikely(ret)) {
+ BT_LOGE("Cannot serialize string field: ret=%d", ret);
+ goto end;
}
end:
- bt_put(character);
- bt_put(character_type);
return ret;
}
struct bt_ctf_field_type *bt_ctf_field_get_type(struct bt_ctf_field *field)
{
- return bt_get(bt_ctf_field_common_borrow_type((void *) field));
+ return bt_ctf_object_get_ref(bt_ctf_field_common_borrow_type((void *) field));
}
enum bt_ctf_field_type_id bt_ctf_field_get_type_id(struct bt_ctf_field *field)
struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index(
struct bt_ctf_field *field, uint64_t index)
{
- return bt_get(bt_ctf_field_common_structure_borrow_field_by_index(
+ return bt_ctf_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_index(
(void *) field, index));
}
struct bt_ctf_field *bt_ctf_field_structure_get_field_by_name(
struct bt_ctf_field *field, const char *name)
{
- return bt_get(bt_ctf_field_common_structure_borrow_field_by_name(
+ return bt_ctf_object_get_ref(bt_ctf_field_common_structure_borrow_field_by_name(
(void *) field, name));
}
struct bt_ctf_field *bt_ctf_field_array_get_field(
struct bt_ctf_field *field, uint64_t index)
{
- return bt_get(
+ return bt_ctf_object_get_ref(
bt_ctf_field_common_array_borrow_field((void *) field, index));
}
struct bt_ctf_field *bt_ctf_field_sequence_get_field(
struct bt_ctf_field *field, uint64_t index)
{
- return bt_get(
+ return bt_ctf_object_get_ref(
bt_ctf_field_common_sequence_borrow_field((void *) field, index));
}
goto end;
}
- bt_put(variant_field->tag);
- variant_field->tag = bt_get(tag_field);
+ bt_ctf_object_put_ref(variant_field->tag);
+ variant_field->tag = bt_ctf_object_get_ref(tag_field);
current_field = bt_ctf_field_variant_get_current_field(field);
BT_ASSERT(current_field);
struct bt_ctf_field *bt_ctf_field_variant_get_current_field(
struct bt_ctf_field *variant_field)
{
- return bt_get(bt_ctf_field_common_variant_borrow_current_field(
+ return bt_ctf_object_get_ref(bt_ctf_field_common_variant_borrow_current_field(
(void *) variant_field));
}
struct bt_ctf_field *bt_ctf_field_enumeration_get_container(
struct bt_ctf_field *field)
{
- return bt_get(bt_ctf_field_enumeration_borrow_container(field));
+ return bt_ctf_object_get_ref(bt_ctf_field_enumeration_borrow_container(field));
}
int bt_ctf_field_integer_signed_get_value(struct bt_ctf_field *field,
if (integer) {
bt_ctf_field_common_initialize(BT_CTF_TO_COMMON(integer), (void *) type,
true,
- (bt_object_release_func) bt_ctf_field_integer_destroy,
+ (bt_ctf_object_release_func) bt_ctf_field_integer_destroy,
&bt_ctf_field_integer_methods);
integer->common.spec.writer.serialize_func =
(bt_ctf_field_serialize_recursive_func) bt_ctf_field_integer_serialize;
bt_ctf_field_common_initialize(BT_CTF_TO_COMMON(enumeration),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_enumeration_destroy_recursive,
&bt_ctf_field_enumeration_methods);
enumeration->container = (void *) bt_ctf_field_create(
BT_CTF_FROM_COMMON(enum_ft->container_ft));
if (!enumeration->container) {
- BT_PUT(enumeration);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(enumeration);
goto end;
}
if (floating_point) {
bt_ctf_field_common_initialize(BT_CTF_TO_COMMON(floating_point),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_floating_point_destroy,
&bt_ctf_field_floating_point_methods);
floating_point->common.spec.writer.serialize_func =
iret = bt_ctf_field_common_structure_initialize(BT_CTF_TO_COMMON(structure),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_structure_destroy_recursive,
&bt_ctf_field_structure_methods,
(bt_ctf_field_common_create_func) bt_ctf_field_create,
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_ctf_object_put_ref);
structure->common.spec.writer.serialize_func =
(bt_ctf_field_serialize_recursive_func) bt_ctf_field_structure_serialize_recursive;
if (iret) {
- BT_PUT(structure);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(structure);
goto end;
}
bt_ctf_field_common_variant_initialize(BT_CTF_TO_COMMON(BT_CTF_TO_COMMON(variant)),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_variant_destroy_recursive,
&bt_ctf_field_variant_methods,
(bt_ctf_field_common_create_func) bt_ctf_field_create,
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_ctf_object_put_ref);
variant->tag = (void *) bt_ctf_field_create(
BT_CTF_FROM_COMMON(var_ft->tag_ft));
variant->common.common.spec.writer.serialize_func =
ret = bt_ctf_field_common_array_initialize(BT_CTF_TO_COMMON(array),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_array_destroy_recursive,
&bt_ctf_field_array_methods,
(bt_ctf_field_common_create_func) bt_ctf_field_create,
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_ctf_object_put_ref);
array->common.spec.writer.serialize_func =
(bt_ctf_field_serialize_recursive_func) bt_ctf_field_array_serialize_recursive;
if (ret) {
- BT_PUT(array);
+ BT_CTF_OBJECT_PUT_REF_AND_RESET(array);
goto end;
}
if (sequence) {
bt_ctf_field_common_sequence_initialize(BT_CTF_TO_COMMON(sequence),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_sequence_destroy_recursive,
&bt_ctf_field_sequence_methods,
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_ctf_object_put_ref);
sequence->common.spec.writer.serialize_func =
(bt_ctf_field_serialize_recursive_func) bt_ctf_field_sequence_serialize_recursive;
BT_LOGD("Created CTF writer sequence field object: addr=%p, ft-addr=%p",
if (string) {
bt_ctf_field_common_string_initialize(BT_CTF_TO_COMMON(string),
(void *) type,
- true, (bt_object_release_func)
+ true, (bt_ctf_object_release_func)
bt_ctf_field_string_destroy,
&bt_ctf_field_string_methods);
string->common.spec.writer.serialize_func =
ret = -1;
goto end;
}
- bt_get(value);
- BT_MOVE(structure->fields->pdata[index], value);
+ bt_ctf_object_get_ref(value);
+ BT_CTF_OBJECT_MOVE_REF(structure->fields->pdata[index], value);
end:
return ret;