Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [ltt-dev] [BABELTRACE PATCH] Free the callbacks on iter_destroy
@ 2011-09-13 20:33 Julien Desfossez
  2011-09-13 21:12 ` Mathieu Desnoyers
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Desfossez @ 2011-09-13 20:33 UTC (permalink / raw)


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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-13 21:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-13 20:33 [ltt-dev] [BABELTRACE PATCH] Free the callbacks on iter_destroy Julien Desfossez
2011-09-13 21:12 ` Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox