Free the callbacks on iter_destroy
authorJulien Desfossez <julien.desfossez@polymtl.ca>
Tue, 13 Sep 2011 21:15:28 +0000 (17:15 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 13 Sep 2011 21:15:28 +0000 (17:15 -0400)
[ edit : use TRUE instead of 1 ]

Signed-off-by: Julien Desfossez <julien.desfossez@polymtl.ca>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace-lib.c

index 176eff3cf9319712a0956bb914d7548bc8695dbe..80c373fee99d4975538dbab7c8eb05398b81639d 100644 (file)
@@ -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, TRUE);
+
+       /* 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, TRUE);
+               }
+               g_array_free(bt_stream_cb->per_id_callbacks, TRUE);
+       }
+
        free(iter);
 }
 
This page took 0.023984 seconds and 4 git commands to generate.