X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=lib%2Fctf-ir%2Fstream.c;h=4eb05a8b6365019e05818c7e6652ce2d18d21af3;hp=70030454d6956c3cdbf68668ce5dc118e23f80d1;hb=312c056ae3d374b253fa0cfe5ed576c0b0e5e569;hpb=d1e4683534e67cc8643ad27536f64f6cc54bc5dc diff --git a/lib/ctf-ir/stream.c b/lib/ctf-ir/stream.c index 70030454..4eb05a8b 100644 --- a/lib/ctf-ir/stream.c +++ b/lib/ctf-ir/stream.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -80,6 +81,7 @@ void bt_stream_destroy(struct bt_object *obj) BT_LOGD("Destroying stream object: addr=%p, name=\"%s\"", stream, bt_stream_get_name(stream)); + bt_object_pool_finalize(&stream->packet_pool); bt_stream_common_finalize((void *) obj); g_free(stream); } @@ -173,6 +175,12 @@ end: return ret; } +static +void bt_stream_free_packet(struct bt_packet *packet, struct bt_stream *stream) +{ + bt_packet_destroy(packet); +} + static struct bt_stream *bt_stream_create_with_id_no_check( struct bt_stream_class *stream_class, @@ -226,6 +234,15 @@ struct bt_stream *bt_stream_create_with_id_no_check( goto error; } + ret = bt_object_pool_initialize(&stream->packet_pool, + (bt_object_pool_new_object_func) bt_packet_new, + (bt_object_pool_destroy_object_func) bt_stream_free_packet, + stream); + if (ret) { + BT_LOGE("Failed to initialize packet pool: ret=%d", ret); + goto error; + } + g_ptr_array_add(trace->common.streams, stream); BT_LOGD("Created stream object: addr=%p", stream); goto end;