summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ec4c2b5)
As of now, the API let the user create multiple iterators on the same
context but the underlying code was not ready. This patch restrict to
only one iterator per context. Supporting multiple iterators is
targetted for the next release.
Fixes #166
[ Edit by Mathieu Desnoyers: update API comment ]
Signed-off-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
GHashTable *trace_handles;
int refcount;
int last_trace_handle_id;
GHashTable *trace_handles;
int refcount;
int last_trace_handle_id;
+ struct bt_iter *current_iterator;
};
#endif /* _BABELTRACE_CONTEXT_INTERNAL_H */
};
#endif /* _BABELTRACE_CONTEXT_INTERNAL_H */
* By default, if begin_pos is NULL, a BT_SEEK_CUR is performed at
* creation. By default, if end_pos is NULL, a BT_SEEK_END (end of
* trace) is the EOF criterion.
* By default, if begin_pos is NULL, a BT_SEEK_CUR is performed at
* creation. By default, if end_pos is NULL, a BT_SEEK_END (end of
* trace) is the EOF criterion.
+ *
+ * Return a pointer to the newly allocated iterator.
+ *
+ * Only one iterator can be created against a context. If more than one
+ * iterator is being created for the same context, the second creation
+ * will return NULL. The previous iterator must be destroyed before
+ * creation of the new iterator for this function to succeed.
*/
struct bt_ctf_iter *bt_ctf_iter_create(struct bt_context *ctx,
const struct bt_iter_pos *begin_pos,
*/
struct bt_ctf_iter *bt_ctf_iter_create(struct bt_context *ctx,
const struct bt_iter_pos *begin_pos,
g_direct_equal, NULL,
(GDestroyNotify) bt_trace_handle_destroy);
g_direct_equal, NULL,
(GDestroyNotify) bt_trace_handle_destroy);
+ ctx->current_iterator = NULL;
ctx->tc = g_new0(struct trace_collection, 1);
init_trace_collection(ctx->tc);
ctx->tc = g_new0(struct trace_collection, 1);
init_trace_collection(ctx->tc);
int i, stream_id;
int ret = 0;
int i, stream_id;
int ret = 0;
+ if (ctx->current_iterator) {
+ ret = -1;
+ goto error_ctx;
+ }
+
iter->stream_heap = g_new(struct ptr_heap, 1);
iter->end_pos = end_pos;
bt_context_get(ctx);
iter->stream_heap = g_new(struct ptr_heap, 1);
iter->end_pos = end_pos;
bt_context_get(ctx);
+ ctx->current_iterator = iter;
return 0;
error:
heap_free(iter->stream_heap);
error_heap_init:
g_free(iter->stream_heap);
return 0;
error:
heap_free(iter->stream_heap);
error_heap_init:
g_free(iter->stream_heap);
heap_free(iter->stream_heap);
g_free(iter->stream_heap);
}
heap_free(iter->stream_heap);
g_free(iter->stream_heap);
}
+ iter->ctx->current_iterator = NULL;
bt_context_put(iter->ctx);
}
bt_context_put(iter->ctx);
}