From 26e21a82c47a15d1080dc142cb20c0b0b0b5a929 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 13 Jun 2018 11:39:07 -0400 Subject: [PATCH] lib: remove internal stream destroy listener API This API is not used anymore. Signed-off-by: Philippe Proulx --- include/babeltrace/ctf-ir/event-internal.h | 8 +++ include/babeltrace/ctf-ir/stream-internal.h | 19 ------ lib/ctf-ir/stream.c | 66 --------------------- lib/graph/iterator.c | 25 +------- 4 files changed, 10 insertions(+), 108 deletions(-) diff --git a/include/babeltrace/ctf-ir/event-internal.h b/include/babeltrace/ctf-ir/event-internal.h index fe5e64de..193a3813 100644 --- a/include/babeltrace/ctf-ir/event-internal.h +++ b/include/babeltrace/ctf-ir/event-internal.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -359,6 +360,13 @@ void bt_event_set_packet(struct bt_event *event, struct bt_packet *packet) BT_ASSERT_PRE_NON_NULL(event, "Event"); BT_ASSERT_PRE_NON_NULL(packet, "Packet"); BT_ASSERT_PRE_EVENT_COMMON_HOT(BT_TO_COMMON(event), "Event"); + BT_ASSERT_PRE(bt_event_class_borrow_stream_class( + BT_FROM_COMMON(event->common.class)) == + BT_FROM_COMMON(packet->stream->common.stream_class), + "Packet's stream class and event's stream class differ: " + "%![event-]+e, %![packet-]+a", + event, packet); + BT_ASSERT(!event->packet); event->packet = packet; bt_object_get_no_null_check_no_parent_check(&event->packet->base); diff --git a/include/babeltrace/ctf-ir/stream-internal.h b/include/babeltrace/ctf-ir/stream-internal.h index 245fd781..87f3c848 100644 --- a/include/babeltrace/ctf-ir/stream-internal.h +++ b/include/babeltrace/ctf-ir/stream-internal.h @@ -39,22 +39,11 @@ struct bt_stream_class; struct bt_stream_common; -typedef void (*bt_stream_common_destroy_listener_func)( - struct bt_stream_common *stream, void *data); - -struct bt_stream_common_destroy_listener { - bt_stream_common_destroy_listener_func func; - void *data; -}; - struct bt_stream_common { struct bt_object base; int64_t id; struct bt_stream_class_common *stream_class; GString *name; - - /* Array of struct bt_stream_common_destroy_listener */ - GArray *destroy_listeners; }; struct bt_stream { @@ -64,14 +53,6 @@ struct bt_stream { struct bt_object_pool packet_pool; }; -BT_HIDDEN -void bt_stream_common_add_destroy_listener(struct bt_stream_common *stream, - bt_stream_common_destroy_listener_func func, void *data); - -BT_HIDDEN -void bt_stream_common_remove_destroy_listener(struct bt_stream_common *stream, - bt_stream_common_destroy_listener_func func, void *data); - BT_HIDDEN int bt_stream_common_initialize( struct bt_stream_common *stream, diff --git a/lib/ctf-ir/stream.c b/lib/ctf-ir/stream.c index 8e5b18c5..2e7c2b4e 100644 --- a/lib/ctf-ir/stream.c +++ b/lib/ctf-ir/stream.c @@ -47,31 +47,12 @@ BT_HIDDEN void bt_stream_common_finalize(struct bt_stream_common *stream) { - int i; - BT_LOGD("Finalizing common stream object: addr=%p, name=\"%s\"", stream, bt_stream_common_get_name(stream)); - /* Call destroy listeners in reverse registration order */ - if (stream->destroy_listeners) { - for (i = stream->destroy_listeners->len - 1; i >= 0; i--) { - struct bt_stream_common_destroy_listener *listener = - &g_array_index(stream->destroy_listeners, - struct bt_stream_common_destroy_listener, i); - - BT_LOGD("Calling destroy listener: func=%p, data=%p, index=%d", - listener->func, listener->data, i); - listener->func(stream, listener->data); - } - } - if (stream->name) { g_string_free(stream->name, TRUE); } - - if (stream->destroy_listeners) { - g_array_free(stream->destroy_listeners, TRUE); - } } static @@ -147,12 +128,6 @@ int bt_stream_common_initialize( bt_object_set_parent(&stream->base, &trace->base); stream->stream_class = stream_class; stream->id = (int64_t) id; - stream->destroy_listeners = g_array_new(FALSE, TRUE, - sizeof(struct bt_stream_common_destroy_listener)); - if (!stream->destroy_listeners) { - BT_LOGE_STR("Failed to allocate a GArray."); - goto error; - } if (name) { stream->name = g_string_new(name); @@ -293,44 +268,3 @@ int64_t bt_stream_get_id(struct bt_stream *stream) { return bt_stream_common_get_id(BT_TO_COMMON(stream)); } - -BT_HIDDEN -void bt_stream_common_add_destroy_listener(struct bt_stream_common *stream, - bt_stream_common_destroy_listener_func func, void *data) -{ - struct bt_stream_common_destroy_listener listener; - - BT_ASSERT(stream); - BT_ASSERT(func); - listener.func = func; - listener.data = data; - g_array_append_val(stream->destroy_listeners, listener); - BT_LOGV("Added stream destroy listener: stream-addr=%p, " - "stream-name=\"%s\", func=%p, data=%p", - stream, bt_stream_common_get_name(stream), func, data); -} - -BT_HIDDEN -void bt_stream_common_remove_destroy_listener(struct bt_stream_common *stream, - bt_stream_common_destroy_listener_func func, void *data) -{ - size_t i; - - BT_ASSERT(stream); - BT_ASSERT(func); - - for (i = 0; i < stream->destroy_listeners->len; i++) { - struct bt_stream_common_destroy_listener *listener = - &g_array_index(stream->destroy_listeners, - struct bt_stream_common_destroy_listener, i); - - if (listener->func == func && listener->data == data) { - g_array_remove_index(stream->destroy_listeners, i); - i--; - BT_LOGV("Removed stream destroy listener: stream-addr=%p, " - "stream-name=\"%s\", func=%p, data=%p", - stream, bt_stream_common_get_name(stream), - func, data); - } - } -} diff --git a/lib/graph/iterator.c b/lib/graph/iterator.c index 2c83d47b..5135bcee 100644 --- a/lib/graph/iterator.c +++ b/lib/graph/iterator.c @@ -77,15 +77,7 @@ struct stream_state { bt_bool is_ended; }; -static -void stream_destroy_listener(struct bt_stream_common *stream, void *data) -{ - struct bt_notification_iterator_private_connection *iterator = data; - - /* Remove associated stream state */ - g_hash_table_remove(iterator->stream_states, stream); -} - +BT_ASSERT_PRE_FUNC static void destroy_stream_state(struct stream_state *stream_state) { @@ -103,6 +95,7 @@ void destroy_stream_state(struct stream_state *stream_state) g_free(stream_state); } +BT_ASSERT_PRE_FUNC static struct stream_state *create_stream_state(struct bt_stream *stream) { @@ -171,20 +164,6 @@ void bt_private_connection_notification_iterator_destroy(struct bt_object *obj) * listener would be called with an invalid/other * notification iterator object. */ - GHashTableIter ht_iter; - gpointer stream_gptr, stream_state_gptr; - - g_hash_table_iter_init(&ht_iter, iterator->stream_states); - - while (g_hash_table_iter_next(&ht_iter, &stream_gptr, &stream_state_gptr)) { - BT_ASSERT(stream_gptr); - - BT_LOGD_STR("Removing stream's destroy listener for notification iterator."); - bt_stream_common_remove_destroy_listener( - (void *) stream_gptr, stream_destroy_listener, - iterator); - } - g_hash_table_destroy(iterator->stream_states); } -- 2.34.1