#include <string.h>
#include <assert.h>
#include <string.h>
-#include <babeltrace/ctf-writer/ref-internal.h>
+#include <babeltrace/ref-internal.h>
#include <babeltrace/compiler.h>
-#include <glib.h>
#include <babeltrace/objects.h>
+#include <glib.h>
#define BT_OBJECT_FROM_CONCRETE(_concrete) ((struct bt_object *) (_concrete))
#define BT_OBJECT_TO_BOOL(_base) ((struct bt_object_bool *) (_base))
struct bt_object {
enum bt_object_type type;
- struct bt_ctf_ref ref_count;
+ struct bt_ref ref_count;
bool is_frozen;
};
GHashTable *ght;
};
+static
+void bt_object_destroy(struct bt_ref *ref_count);
+
static
void bt_object_string_destroy(struct bt_object *object)
{
static
struct bt_object *bt_object_array_copy(const struct bt_object *array_obj)
{
- int x;
+ int i;
int ret;
struct bt_object *copy_obj;
struct bt_object_array *typed_array_obj;
goto end;
}
- for (x = 0; x < typed_array_obj->garray->len; ++x) {
+ for (i = 0; i < typed_array_obj->garray->len; ++i) {
struct bt_object *element_obj_copy;
struct bt_object *element_obj =
- bt_object_array_get(array_obj, x);
+ bt_object_array_get(array_obj, i);
if (!element_obj) {
BT_OBJECT_PUT(copy_obj);
bool bt_object_array_compare(const struct bt_object *object_a,
const struct bt_object *object_b)
{
- int x;
+ int i;
bool ret = true;
const struct bt_object_array *array_obj_a =
BT_OBJECT_TO_ARRAY(object_a);
goto end;
}
- for (x = 0; x < array_obj_a->garray->len; ++x) {
+ for (i = 0; i < array_obj_a->garray->len; ++i) {
struct bt_object *element_obj_a;
struct bt_object *element_obj_b;
- element_obj_a = bt_object_array_get(object_a, x);
- element_obj_b = bt_object_array_get(object_b, x);
+ element_obj_a = bt_object_array_get(object_a, i);
+ element_obj_b = bt_object_array_get(object_b, i);
if (!bt_object_compare(element_obj_a, element_obj_b)) {
BT_OBJECT_PUT(element_obj_a);
void bt_object_array_freeze(struct bt_object *object)
{
- int x;
+ int i;
struct bt_object_array *typed_array_obj =
BT_OBJECT_TO_ARRAY(object);
- for (x = 0; x < typed_array_obj->garray->len; ++x) {
+ for (i = 0; i < typed_array_obj->garray->len; ++i) {
struct bt_object *element_obj =
- g_ptr_array_index(typed_array_obj->garray, x);
+ g_ptr_array_index(typed_array_obj->garray, i);
bt_object_freeze(element_obj);
}
};
static
-void bt_object_destroy(struct bt_ctf_ref *ref_count)
+void bt_object_destroy(struct bt_ref *ref_count)
{
struct bt_object *object;
void bt_object_get(struct bt_object *object)
{
- if (!object) {
- goto skip;
+ if (object && !bt_object_is_null(object)) {
+ bt_ref_get(&object->ref_count);
}
- bt_ctf_ref_get(&object->ref_count);
-
-skip:
return;
}
void bt_object_put(struct bt_object *object)
{
- if (!object) {
- goto skip;
+ if (object && !bt_object_is_null(object)) {
+ bt_ref_put(&object->ref_count);
}
-
- bt_ctf_ref_put(&object->ref_count, bt_object_destroy);
-
-skip:
- return;
}
enum bt_object_status bt_object_freeze(struct bt_object *object)
base.type = type;
base.is_frozen = false;
- bt_ctf_ref_init(&base.ref_count);
+ bt_ref_init(&base.ref_count, bt_object_destroy);
return base;
}