X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fgraph%2Fcomponent-class-sink-colander.c;h=0df9ed4e6016a0bf3a6c0e5abc783e3301a0a857;hb=8ed535b5ed7341916a1dd486b87bdc6e94ed1b81;hp=0d83e5d3be22aed42802e5f99640eb3add7d0cda;hpb=90157d89276ed1a569a2d4ffcfeed0b415817c12;p=babeltrace.git diff --git a/lib/graph/component-class-sink-colander.c b/lib/graph/component-class-sink-colander.c index 0d83e5d3..0df9ed4e 100644 --- a/lib/graph/component-class-sink-colander.c +++ b/lib/graph/component-class-sink-colander.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -35,6 +36,7 @@ struct bt_component_class *colander_comp_cls; struct colander_data { struct bt_notification **user_notif; + enum bt_notification_type *notif_types; struct bt_notification_iterator *notif_iter; }; @@ -45,6 +47,9 @@ enum bt_component_status colander_init( { enum bt_component_status status = BT_COMPONENT_STATUS_OK; struct colander_data *colander_data = NULL; + struct bt_component_class_sink_colander_data *user_provided_data = + init_method_data; + const enum bt_notification_type *notif_type; if (!init_method_data) { BT_LOGW_STR("Component initialization method data is NULL."); @@ -59,7 +64,31 @@ enum bt_component_status colander_init( goto end; } - colander_data->user_notif = init_method_data; + colander_data->user_notif = user_provided_data->notification; + + if (user_provided_data->notification_types) { + notif_type = user_provided_data->notification_types; + unsigned long count; + + while (*notif_type != BT_NOTIFICATION_TYPE_SENTINEL) { + notif_type++; + } + + count = notif_type - user_provided_data->notification_types + 1; + + colander_data->notif_types = + g_new0(enum bt_notification_type, count); + if (!colander_data->notif_types) { + BT_LOGE_STR("Failed to allocate an array of notification types."); + status = BT_COMPONENT_STATUS_NOMEM; + goto end; + } + + memcpy(colander_data->notif_types, + user_provided_data->notification_types, + count * sizeof(enum bt_notification_type)); + } + status = bt_private_component_sink_add_input_private_port( priv_comp, "in", NULL, NULL); if (status != BT_COMPONENT_STATUS_OK) { @@ -87,6 +116,7 @@ void colander_finalize(struct bt_private_component *priv_comp) bt_put(colander_data->notif_iter); } + g_free(colander_data->notif_types); g_free(colander_data); } @@ -105,7 +135,8 @@ void colander_port_connected(struct bt_private_component *priv_comp, assert(colander_data); BT_PUT(colander_data->notif_iter); conn_status = bt_private_connection_create_notification_iterator( - priv_conn, NULL, &colander_data->notif_iter); + priv_conn, colander_data->notif_types, + &colander_data->notif_iter); if (conn_status) { BT_LOGE("Cannot create notification iterator from connection: " "comp-addr=%p, conn-addr=%p", priv_comp, priv_conn);