#include <string.h>
#include <inttypes.h>
#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/values.h>
#include <babeltrace/compat/glib-internal.h>
#include <babeltrace/types.h>
BT_LOGE("Cannot copy array value's element: "
"array-addr=%p, index=%d",
array_obj, i);
- BT_PUT(copy_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
goto end;
}
ret = bt_value_array_append_element(copy_obj, element_obj_copy);
- BT_PUT(element_obj_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
if (ret) {
BT_LOGE("Cannot append to array value: addr=%p",
array_obj);
- BT_PUT(copy_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
goto end;
}
}
BT_LOGE("Cannot copy map value's element: "
"map-addr=%p, key=\"%s\"",
map_obj, key_str);
- BT_PUT(copy_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
goto end;
}
ret = bt_value_map_insert_entry(copy_obj, key_str, element_obj_copy);
- BT_PUT(element_obj_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
if (ret) {
BT_LOGE("Cannot insert into map value: addr=%p, key=\"%s\"",
map_obj, key_str);
- BT_PUT(copy_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
goto end;
}
}
array_obj->base = bt_value_create_base(BT_VALUE_TYPE_ARRAY);
array_obj->garray = bt_g_ptr_array_new_full(0,
- (GDestroyNotify) bt_put);
+ (GDestroyNotify) bt_object_put_ref);
if (!array_obj->garray) {
BT_LOGE_STR("Failed to allocate a GPtrArray.");
g_free(array_obj);
map_obj->base = bt_value_create_base(BT_VALUE_TYPE_MAP);
map_obj->ght = g_hash_table_new_full(g_direct_hash, g_direct_equal,
- NULL, (GDestroyNotify) bt_put);
+ NULL, (GDestroyNotify) bt_object_put_ref);
if (!map_obj->ght) {
BT_LOGE_STR("Failed to allocate a GHashTable.");
g_free(map_obj);
BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object");
g_ptr_array_add(typed_array_obj->garray, element_obj);
- bt_get(element_obj);
+ bt_object_get_ref(element_obj);
BT_LOGV("Appended element to array value: array-value-addr=%p, "
"element-value-addr=%p, new-size=%u",
array_obj, element_obj, typed_array_obj->garray->len);
bool_obj = bt_value_bool_create_init(val);
ret = bt_value_array_append_element(array_obj, bool_obj);
- bt_put(bool_obj);
+ bt_object_put_ref(bool_obj);
return ret;
}
integer_obj = bt_value_integer_create_init(val);
ret = bt_value_array_append_element(array_obj, integer_obj);
- bt_put(integer_obj);
+ bt_object_put_ref(integer_obj);
return ret;
}
real_obj = bt_value_real_create_init(val);
ret = bt_value_array_append_element(array_obj, real_obj);
- bt_put(real_obj);
+ bt_object_put_ref(real_obj);
return ret;
}
string_obj = bt_value_string_create_init(val);
ret = bt_value_array_append_element(array_obj, string_obj);
- bt_put(string_obj);
+ bt_object_put_ref(string_obj);
return ret;
}
empty_array_obj = bt_value_array_create();
ret = bt_value_array_append_element(array_obj, empty_array_obj);
- bt_put(empty_array_obj);
+ bt_object_put_ref(empty_array_obj);
return ret;
}
map_obj = bt_value_map_create();
ret = bt_value_array_append_element(array_obj, map_obj);
- bt_put(map_obj);
+ bt_object_put_ref(map_obj);
return ret;
}
BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object");
BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index,
typed_array_obj->garray->len);
- bt_put(g_ptr_array_index(typed_array_obj->garray, index));
+ bt_object_put_ref(g_ptr_array_index(typed_array_obj->garray, index));
g_ptr_array_index(typed_array_obj->garray, index) = element_obj;
- bt_get(element_obj);
+ bt_object_get_ref(element_obj);
BT_LOGV("Set array value's element: array-value-addr=%p, "
"index=%" PRIu64 ", element-value-addr=%p",
array_obj, index, element_obj);
BT_ASSERT_PRE_VALUE_HOT(map_obj, "Map value object");
g_hash_table_insert(BT_VALUE_TO_MAP(map_obj)->ght,
GUINT_TO_POINTER(g_quark_from_string(key)), element_obj);
- bt_get(element_obj);
+ bt_object_get_ref(element_obj);
BT_LOGV("Inserted value into map value: map-value-addr=%p, "
"key=\"%s\", element-value-addr=%p",
map_obj, key, element_obj);
bool_obj = bt_value_bool_create_init(val);
ret = bt_value_map_insert_entry(map_obj, key, bool_obj);
- bt_put(bool_obj);
+ bt_object_put_ref(bool_obj);
return ret;
}
integer_obj = bt_value_integer_create_init(val);
ret = bt_value_map_insert_entry(map_obj, key, integer_obj);
- bt_put(integer_obj);
+ bt_object_put_ref(integer_obj);
return ret;
}
real_obj = bt_value_real_create_init(val);
ret = bt_value_map_insert_entry(map_obj, key, real_obj);
- bt_put(real_obj);
+ bt_object_put_ref(real_obj);
return ret;
}
string_obj = bt_value_string_create_init(val);
ret = bt_value_map_insert_entry(map_obj, key, string_obj);
- bt_put(string_obj);
+ bt_object_put_ref(string_obj);
return ret;
}
array_obj = bt_value_array_create();
ret = bt_value_map_insert_entry(map_obj, key, array_obj);
- bt_put(array_obj);
+ bt_object_put_ref(array_obj);
return ret;
}
empty_map_obj = bt_value_map_create();
ret = bt_value_map_insert_entry(map_obj, key, empty_map_obj);
- bt_put(empty_map_obj);
+ bt_object_put_ref(empty_map_obj);
return ret;
}
extend_data->got_error = BT_TRUE;
end:
- BT_PUT(extension_obj_elem_copy);
+ BT_OBJECT_PUT_REF_AND_RESET(extension_obj_elem_copy);
return ret;
}
goto end;
error:
- BT_PUT(extended_obj);
+ BT_OBJECT_PUT_REF_AND_RESET(extended_obj);
end:
return extended_obj;