X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=lib%2Fiterator.c;h=0af151402b429d3fe95d9c92c42e9e07eb9436f5;hp=bf87193a3b64f8bdf491fc5ba309f4ca4ae80e82;hb=48d5f76c4831624cb4332c7707c2615c2474284c;hpb=e419579102094d83539d79ce6af83d9786d387ee diff --git a/lib/iterator.c b/lib/iterator.c index bf87193a..0af15140 100644 --- a/lib/iterator.c +++ b/lib/iterator.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -111,8 +110,7 @@ static int seek_file_stream_by_timestamp(struct ctf_file_stream *cfs, for (i = 0; i < stream_pos->packet_index->len; i++) { index = &g_array_index(stream_pos->packet_index, struct packet_index, i); - if (index->timestamp_begin >= timestamp || - index->timestamp_end <= timestamp) + if (index->timestamp_end <= timestamp) continue; stream_pos->packet_seek(&stream_pos->parent, i, SEEK_SET); @@ -178,7 +176,7 @@ int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *iter_pos) switch (iter_pos->type) { case BT_SEEK_RESTORE: if (!iter_pos->u.restore) - goto error_arg; + return -EINVAL; heap_free(iter->stream_heap); ret = heap_init(iter->stream_heap, 0, stream_compare); @@ -229,9 +227,6 @@ int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *iter_pos) case BT_SEEK_TIME: tc = iter->ctx->tc; - if (!iter_pos->u.seek_time) - goto error_arg; - heap_free(iter->stream_heap); ret = heap_init(iter->stream_heap, 0, stream_compare); if (ret < 0) @@ -254,13 +249,11 @@ int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *iter_pos) return 0; default: /* not implemented */ - goto error_arg; + return -EINVAL; } return 0; -error_arg: - ret = -EINVAL; error: heap_free(iter->stream_heap); if (heap_init(iter->stream_heap, 0, stream_compare) < 0) { @@ -445,10 +438,6 @@ int bt_iter_init(struct bt_iter *iter, iter->stream_heap = g_new(struct ptr_heap, 1); iter->end_pos = end_pos; - iter->callbacks = g_array_new(0, 1, sizeof(struct bt_stream_callbacks)); - iter->recalculate_dep_graph = 0; - iter->main_callbacks.callback = NULL; - iter->dep_gc = g_ptr_array_new(); bt_context_get(ctx); iter->ctx = ctx; @@ -524,35 +513,10 @@ struct bt_iter *bt_iter_create(struct bt_context *ctx, void bt_iter_fini(struct bt_iter *iter) { - struct bt_stream_callbacks *bt_stream_cb; - struct bt_callback_chain *bt_chain; - int i, j; - if (iter->stream_heap) { heap_free(iter->stream_heap); g_free(iter->stream_heap); } - - /* free all events callbacks */ - if (iter->main_callbacks.callback) - g_array_free(iter->main_callbacks.callback, TRUE); - - /* free per-event callbacks */ - for (i = 0; i < iter->callbacks->len; i++) { - bt_stream_cb = &g_array_index(iter->callbacks, - struct bt_stream_callbacks, i); - if (!bt_stream_cb || !bt_stream_cb->per_id_callbacks) - continue; - for (j = 0; j < bt_stream_cb->per_id_callbacks->len; j++) { - bt_chain = &g_array_index(bt_stream_cb->per_id_callbacks, - struct bt_callback_chain, j); - if (bt_chain->callback) { - g_array_free(bt_chain->callback, TRUE); - } - } - g_array_free(bt_stream_cb->per_id_callbacks, TRUE); - } - bt_context_put(iter->ctx); }