[ltt-dev] [BABELTRACE PATCH] Free the callbacks on iter_destroy

Julien Desfossez julien.desfossez at polymtl.ca
Tue Sep 13 16:33:05 EDT 2011


Signed-off-by: Julien Desfossez <julien.desfossez at polymtl.ca>
---
 converter/babeltrace-lib.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/converter/babeltrace-lib.c b/converter/babeltrace-lib.c
index 176eff3..3e17bf9 100644
--- a/converter/babeltrace-lib.c
+++ b/converter/babeltrace-lib.c
@@ -406,8 +406,31 @@ error_malloc:
 
 void babeltrace_iter_destroy(struct babeltrace_iter *iter)
 {
+	struct bt_stream_callbacks *bt_stream_cb;
+	struct bt_callback_chain *bt_chain;
+	int i, j;
+
 	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, 1);
+
+	/* 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);
+			g_array_free(bt_chain->callback, 1);
+		}
+		g_array_free(bt_stream_cb->per_id_callbacks, 1);
+	}
+
 	free(iter);
 }
 
-- 
1.7.5.4





More information about the lttng-dev mailing list