lib: make public reference count functions have strict types
[babeltrace.git] / plugins / utils / counter / counter.c
index f9ce107fba52b935e55cf19dc9e39df87cf01657..ba4c521e10408a157c7394bd4c810c1cdd5bcd78 100644 (file)
@@ -103,7 +103,7 @@ void try_print_last(struct counter *counter)
 
 void destroy_private_counter_data(struct counter *counter)
 {
-       bt_object_put_ref(counter->notif_iter);
+       bt_self_component_port_input_notification_iterator_put_ref(counter->notif_iter);
        g_free(counter);
 }
 
@@ -114,22 +114,23 @@ void counter_finalize(struct bt_self_component_sink *comp)
 
        BT_ASSERT(comp);
        counter = bt_self_component_get_data(
-                       bt_self_component_sink_borrow_self_component(comp));
+                       bt_self_component_sink_as_self_component(comp));
        BT_ASSERT(counter);
        try_print_last(counter);
-       bt_object_put_ref(counter->notif_iter);
+       bt_self_component_port_input_notification_iterator_put_ref(counter->notif_iter);
        g_free(counter);
 }
 
 BT_HIDDEN
 enum bt_self_component_status counter_init(
                struct bt_self_component_sink *component,
-               struct bt_value *params, UNUSED_VAR void *init_method_data)
+               const struct bt_value *params,
+               UNUSED_VAR void *init_method_data)
 {
        enum bt_self_component_status ret;
        struct counter *counter = g_new0(struct counter, 1);
-       struct bt_value *step = NULL;
-       struct bt_value *hide_zero = NULL;
+       const struct bt_value *step = NULL;
+       const struct bt_value *hide_zero = NULL;
 
        if (!counter) {
                ret = BT_SELF_COMPONENT_STATUS_NOMEM;
@@ -144,7 +145,7 @@ enum bt_self_component_status counter_init(
 
        counter->last_printed_total = -1ULL;
        counter->step = 1000;
-       step = bt_value_map_borrow_entry_value(params, "step");
+       step = bt_value_map_borrow_entry_value_const(params, "step");
        if (step && bt_value_is_integer(step)) {
                int64_t val;
 
@@ -154,7 +155,7 @@ enum bt_self_component_status counter_init(
                }
        }
 
-       hide_zero = bt_value_map_borrow_entry_value(params, "hide-zero");
+       hide_zero = bt_value_map_borrow_entry_value_const(params, "hide-zero");
        if (hide_zero && bt_value_is_bool(hide_zero)) {
                bt_bool val;
 
@@ -163,7 +164,7 @@ enum bt_self_component_status counter_init(
        }
 
        bt_self_component_set_data(
-               bt_self_component_sink_borrow_self_component(component),
+               bt_self_component_sink_as_self_component(component),
                counter);
        goto end;
 
@@ -178,14 +179,14 @@ BT_HIDDEN
 enum bt_self_component_status counter_port_connected(
                struct bt_self_component_sink *comp,
                struct bt_self_component_port_input *self_port,
-               struct bt_port_output *other_port)
+               const struct bt_port_output *other_port)
 {
        enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
        struct counter *counter;
        struct bt_self_component_port_input_notification_iterator *iterator;
 
        counter = bt_self_component_get_data(
-               bt_self_component_sink_borrow_self_component(comp));
+               bt_self_component_sink_as_self_component(comp));
        BT_ASSERT(counter);
        iterator = bt_self_component_port_input_notification_iterator_create(
                self_port);
@@ -194,7 +195,8 @@ enum bt_self_component_status counter_port_connected(
                goto end;
        }
 
-       BT_OBJECT_MOVE_REF(counter->notif_iter, iterator);
+       BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_MOVE_REF(
+               counter->notif_iter, iterator);
 
 end:
        return status;
@@ -208,10 +210,10 @@ enum bt_self_component_status counter_consume(
        struct counter *counter;
        enum bt_notification_iterator_status it_ret;
        uint64_t notif_count;
-       bt_notification_array notifs;
+       bt_notification_array_const notifs;
 
        counter = bt_self_component_get_data(
-                       bt_self_component_sink_borrow_self_component(comp));
+                       bt_self_component_sink_as_self_component(comp));
        BT_ASSERT(counter);
 
        if (unlikely(!counter->notif_iter)) {
@@ -234,7 +236,7 @@ enum bt_self_component_status counter_consume(
                uint64_t i;
 
                for (i = 0; i < notif_count; i++) {
-                       struct bt_notification *notif = notifs[i];
+                       const struct bt_notification *notif = notifs[i];
 
                        BT_ASSERT(notif);
                        switch (bt_notification_get_type(notif)) {
@@ -244,13 +246,13 @@ enum bt_self_component_status counter_consume(
                        case BT_NOTIFICATION_TYPE_INACTIVITY:
                                counter->count.inactivity++;
                                break;
-                       case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
+                       case BT_NOTIFICATION_TYPE_STREAM_BEGINNING:
                                counter->count.stream_begin++;
                                break;
                        case BT_NOTIFICATION_TYPE_STREAM_END:
                                counter->count.stream_end++;
                                break;
-                       case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
+                       case BT_NOTIFICATION_TYPE_PACKET_BEGINNING:
                                counter->count.packet_begin++;
                                break;
                        case BT_NOTIFICATION_TYPE_PACKET_END:
@@ -260,7 +262,7 @@ enum bt_self_component_status counter_consume(
                                counter->count.other++;
                        }
 
-                       bt_object_put_ref(notif);
+                       bt_notification_put_ref(notif);
                }
 
                ret = BT_SELF_COMPONENT_STATUS_OK;
This page took 0.025433 seconds and 4 git commands to generate.