GHashTable *trace_handles;
int refcount;
int last_trace_handle_id;
+ struct bt_iter *current_iterator;
};
#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.
+ *
+ * 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,
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);
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);
}
}
+ ctx->current_iterator = iter;
return 0;
error:
heap_free(iter->stream_heap);
error_heap_init:
g_free(iter->stream_heap);
+error_ctx:
return ret;
}
heap_free(iter->stream_heap);
g_free(iter->stream_heap);
}
+ iter->ctx->current_iterator = NULL;
bt_context_put(iter->ctx);
}