X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fir%2Fclock.c;h=723b860dd6e9d377ccf6e7e0f442358720caa4e4;hb=83509119a945fc77faff869daaf48627e1c4b3fa;hp=45ed14762512d72dd5cd4b23ca396da7140e6907;hpb=e1ae7645ef265eb69a0a500c8f4d6620c50543da;p=babeltrace.git diff --git a/formats/ctf/ir/clock.c b/formats/ctf/ir/clock.c index 45ed1476..723b860d 100644 --- a/formats/ctf/ir/clock.c +++ b/formats/ctf/ir/clock.c @@ -27,12 +27,15 @@ */ #include +#include +#include #include +#include #include #include static -void bt_ctf_clock_destroy(struct bt_ctf_ref *ref); +void bt_ctf_clock_destroy(struct bt_object *obj); BT_HIDDEN struct bt_ctf_clock *_bt_ctf_clock_create(void) @@ -46,7 +49,7 @@ struct bt_ctf_clock *_bt_ctf_clock_create(void) clock->precision = 1; clock->frequency = 1000000000; - bt_ctf_ref_init(&clock->ref_count); + bt_object_init(clock, bt_ctf_clock_destroy); end: return clock; } @@ -57,7 +60,7 @@ int bt_ctf_clock_set_name(struct bt_ctf_clock *clock, { int ret = 0; - if (validate_identifier(name)) { + if (bt_ctf_validate_identifier(name)) { ret = -1; goto end; } @@ -88,20 +91,19 @@ struct bt_ctf_clock *bt_ctf_clock_create(const char *name) ret = bt_ctf_clock_set_name(clock, name); if (ret) { - goto error_destroy; + goto error; } ret = babeltrace_uuid_generate(clock->uuid); if (ret) { - goto error_destroy; + goto error; } clock->uuid_set = 1; return clock; -error_destroy: - bt_ctf_clock_destroy(&clock->ref_count); error: - return NULL; + BT_PUT(clock); + return clock; } const char *bt_ctf_clock_get_name(struct bt_ctf_clock *clock) @@ -344,20 +346,12 @@ end: void bt_ctf_clock_get(struct bt_ctf_clock *clock) { - if (!clock) { - return; - } - - bt_ctf_ref_get(&clock->ref_count); + bt_get(clock); } void bt_ctf_clock_put(struct bt_ctf_clock *clock) { - if (!clock) { - return; - } - - bt_ctf_ref_put(&clock->ref_count, bt_ctf_clock_destroy); + bt_put(clock); } BT_HIDDEN @@ -390,7 +384,7 @@ void bt_ctf_clock_serialize(struct bt_ctf_clock *clock, uuid[4], uuid[5], uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]); - if (clock->description->len) { + if (clock->description) { g_string_append_printf(context->string, "\tdescription = \"%s\";\n", clock->description->str); } @@ -409,15 +403,11 @@ void bt_ctf_clock_serialize(struct bt_ctf_clock *clock, } static -void bt_ctf_clock_destroy(struct bt_ctf_ref *ref) +void bt_ctf_clock_destroy(struct bt_object *obj) { struct bt_ctf_clock *clock; - if (!ref) { - return; - } - - clock = container_of(ref, struct bt_ctf_clock, ref_count); + clock = container_of(obj, struct bt_ctf_clock, base); if (clock->name) { g_string_free(clock->name, TRUE); }