X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fgraph%2Fnotification%2Fstream.c;h=68b999c0c6e0d36c7c02d0eea5f8b58656684b17;hb=3230ee6b4f3a704958b761daecae835c56938bc9;hp=68b9bcdb8b193e2c46375b51f5a29375c8e6ca06;hpb=43350437a513e8ed1a158ff3013eb5efefd3dc3b;p=babeltrace.git diff --git a/lib/graph/notification/stream.c b/lib/graph/notification/stream.c index 68b9bcdb..68b999c0 100644 --- a/lib/graph/notification/stream.c +++ b/lib/graph/notification/stream.c @@ -25,6 +25,7 @@ */ #include +#include #include static @@ -42,7 +43,7 @@ struct bt_notification *bt_notification_stream_end_create( { struct bt_notification_stream_end *notification; - if (!stream) { + if (!stream || stream->pos.fd >= 0) { goto error; } @@ -65,3 +66,42 @@ struct bt_ctf_packet *bt_notification_stream_end_get_stream( struct bt_notification_stream_end, parent); return bt_get(stream_end->stream); } + +static +void bt_notification_stream_begin_destroy(struct bt_object *obj) +{ + struct bt_notification_stream_begin *notification = + (struct bt_notification_stream_begin *) obj; + + BT_PUT(notification->stream); + g_free(notification); +} + +struct bt_notification *bt_notification_stream_begin_create( + struct bt_ctf_stream *stream) +{ + struct bt_notification_stream_begin *notification; + + if (!stream || stream->pos.fd >= 0) { + goto error; + } + + notification = g_new0(struct bt_notification_stream_begin, 1); + bt_notification_init(¬ification->parent, + BT_NOTIFICATION_TYPE_STREAM_BEGIN, + bt_notification_stream_begin_destroy); + notification->stream = bt_get(stream); + return ¬ification->parent; +error: + return NULL; +} + +struct bt_ctf_packet *bt_notification_stream_begin_get_stream( + struct bt_notification *notification) +{ + struct bt_notification_stream_begin *stream_begin; + + stream_begin = container_of(notification, + struct bt_notification_stream_begin, parent); + return bt_get(stream_begin->stream); +}