示例#1
0
struct bt_ctf_trace *bt_ctf_trace_create(void)
{
	struct bt_ctf_trace *trace = NULL;

	trace = g_new0(struct bt_ctf_trace, 1);
	if (!trace) {
		goto error;
	}

	bt_ctf_trace_set_byte_order(trace, BT_CTF_BYTE_ORDER_NATIVE);
	bt_object_init(trace, bt_ctf_trace_destroy);
	trace->clocks = g_ptr_array_new_with_free_func(
		(GDestroyNotify) bt_put);
	trace->streams = g_ptr_array_new_with_free_func(
		(GDestroyNotify) bt_put);
	trace->stream_classes = g_ptr_array_new_with_free_func(
		(GDestroyNotify) put_stream_class);
	if (!trace->clocks || !trace->stream_classes || !trace->streams) {
		goto error;
	}

	/* Generate a trace UUID */
	uuid_generate(trace->uuid);
	if (init_trace_packet_header(trace)) {
		goto error;
	}

	/* Create the environment array object */
	trace->environment = bt_ctf_attributes_create();
	if (!trace->environment) {
		goto error;
	}

	return trace;

error:
	BT_PUT(trace);
	return trace;
}
示例#2
0
struct bt_ctf_trace *bt_ctf_trace_create(void)
{
	struct bt_ctf_trace *trace = NULL;

	trace = g_new0(struct bt_ctf_trace, 1);
	if (!trace) {
		goto error;
	}

	bt_ctf_trace_set_byte_order(trace, BT_CTF_BYTE_ORDER_NATIVE);
	bt_ctf_ref_init(&trace->ref_count);
	trace->environment = g_ptr_array_new_with_free_func(
		(GDestroyNotify)environment_variable_destroy);
	trace->clocks = g_ptr_array_new_with_free_func(
		(GDestroyNotify)bt_ctf_clock_put);
	trace->streams = g_ptr_array_new_with_free_func(
		(GDestroyNotify)bt_ctf_stream_put);
	trace->stream_classes = g_ptr_array_new_with_free_func(
		(GDestroyNotify)bt_ctf_stream_class_put);
	if (!trace->environment || !trace->clocks ||
		!trace->stream_classes || !trace->streams) {
		goto error_destroy;
	}

	/* Generate a trace UUID */
	uuid_generate(trace->uuid);
	if (init_trace_packet_header(trace)) {
		goto error_destroy;
	}

	return trace;

error_destroy:
	bt_ctf_trace_destroy(&trace->ref_count);
	trace = NULL;
error:
	return trace;
}