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

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Tue Sep 13 17:12:34 EDT 2011


* Julien Desfossez (julien.desfossez at polymtl.ca) wrote:
> Signed-off-by: Julien Desfossez <julien.desfossez at polymtl.ca>

[ edit : use TRUE instead of 1 ]

merged, thanks!

MAthieu

> ---
>  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
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




More information about the lttng-dev mailing list