lib: simplify the public notification iterator interfaces
[babeltrace.git] / plugins / utils / counter / counter.c
index f3e61e6dc3f40a9c4452f9267660fa96b1b93beb..7ff3d33978759a7a058f607b801db529b91bbb5d 100644 (file)
@@ -149,7 +149,7 @@ enum bt_component_status counter_init(struct bt_private_component *component,
 
        counter->last_printed_total = -1ULL;
        counter->step = 1000;
-       step = bt_value_map_get(params, "step");
+       step = bt_value_map_borrow(params, "step");
        if (step && bt_value_is_integer(step)) {
                int64_t val;
 
@@ -160,7 +160,7 @@ enum bt_component_status counter_init(struct bt_private_component *component,
                }
        }
 
-       hide_zero = bt_value_map_get(params, "hide-zero");
+       hide_zero = bt_value_map_borrow(params, "hide-zero");
        if (hide_zero && bt_value_is_bool(hide_zero)) {
                bt_bool val;
 
@@ -179,8 +179,6 @@ error:
        destroy_private_counter_data(counter);
 
 end:
-       bt_put(step);
-       bt_put(hide_zero);
        return ret;
 }
 
@@ -214,10 +212,10 @@ end:
 enum bt_component_status counter_consume(struct bt_private_component *component)
 {
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-       struct bt_notification *notif = NULL;
        struct counter *counter;
        enum bt_notification_iterator_status it_ret;
        int64_t count;
+       struct bt_notification *notif = NULL;
 
        counter = bt_private_component_get_user_data(component);
        BT_ASSERT(counter);
@@ -234,7 +232,8 @@ enum bt_component_status counter_consume(struct bt_private_component *component)
        }
 
        /* Consume one notification  */
-       it_ret = bt_notification_iterator_next(counter->notif_iter);
+       it_ret = bt_private_connection_notification_iterator_next(
+               counter->notif_iter, &notif);
        if (it_ret < 0) {
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
@@ -250,9 +249,6 @@ enum bt_component_status counter_consume(struct bt_private_component *component)
                goto end;
        case BT_NOTIFICATION_ITERATOR_STATUS_OK:
        {
-               struct bt_notification *notif =
-                       bt_notification_iterator_get_notification(counter->notif_iter);
-
                BT_ASSERT(notif);
                switch (bt_notification_get_type(notif)) {
                case BT_NOTIFICATION_TYPE_EVENT:
@@ -292,8 +288,6 @@ enum bt_component_status counter_consume(struct bt_private_component *component)
                default:
                        counter->count.other++;
                }
-
-               bt_put(notif);
        }
        default:
                break;
This page took 0.025717 seconds and 4 git commands to generate.