lib: pass config objects to component init methods
[babeltrace.git] / src / plugins / utils / counter / counter.c
index f61ee043b0fb26ec99cc49c2d3b37af7a5d838ee..f2cdd1a926337ef7df88ce3b566c034c8a3fefdd 100644 (file)
@@ -23,7 +23,7 @@
 #define BT_COMP_LOG_SELF_COMP (counter->self_comp)
 #define BT_LOG_OUTPUT_LEVEL (counter->log_level)
 #define BT_LOG_TAG "PLUGIN/FLT.UTILS.COUNTER"
-#include "plugins/comp-logging.h"
+#include "logging/comp-logging.h"
 
 #include <babeltrace2/babeltrace.h>
 #include "common/macros.h"
@@ -114,8 +114,11 @@ void try_print_last(struct counter *counter)
 
 void destroy_private_counter_data(struct counter *counter)
 {
-       bt_self_component_port_input_message_iterator_put_ref(counter->msg_iter);
-       g_free(counter);
+       if (counter) {
+               bt_self_component_port_input_message_iterator_put_ref(
+                       counter->msg_iter);
+               g_free(counter);
+       }
 }
 
 BT_HIDDEN
@@ -135,6 +138,7 @@ void counter_finalize(bt_self_component_sink *comp)
 BT_HIDDEN
 bt_component_class_init_method_status counter_init(
                bt_self_component_sink *component,
+               bt_self_component_sink_configuration *config,
                const bt_value *params,
                __attribute__((unused)) void *init_method_data)
 {
@@ -214,25 +218,28 @@ bt_component_class_sink_graph_is_configured_method_status
 counter_graph_is_configured(
                bt_self_component_sink *comp)
 {
-       bt_component_class_sink_graph_is_configured_method_status status =
-               BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK;
+       bt_component_class_sink_graph_is_configured_method_status status;
+       bt_self_component_port_input_message_iterator_create_from_sink_component_status
+               msg_iter_status;
        struct counter *counter;
        bt_self_component_port_input_message_iterator *iterator;
 
        counter = bt_self_component_get_data(
                bt_self_component_sink_as_self_component(comp));
        BT_ASSERT(counter);
-       iterator = bt_self_component_port_input_message_iterator_create_from_sink_component(
+
+       msg_iter_status = bt_self_component_port_input_message_iterator_create_from_sink_component(
                comp, bt_self_component_sink_borrow_input_port_by_name(comp,
-                       in_port_name));
-       if (!iterator) {
-               status = BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_MEMORY_ERROR;
+                       in_port_name), &iterator);
+       if (msg_iter_status != BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_OK) {
+               status = (int) msg_iter_status;
                goto end;
        }
 
        BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_MOVE_REF(
                counter->msg_iter, iterator);
 
+       status = BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK;
 end:
        return status;
 }
This page took 0.024108 seconds and 4 git commands to generate.