[PATCH 02/10] clients: Free resources on exit in eventdemo

Pekka Paalanen ppaalanen at gmail.com
Sun Jul 8 00:23:19 PDT 2012


Hi,


On Sun,  8 Jul 2012 03:03:39 +0200
Martin Olsson <martin at minimum.se> wrote:

> ---
>  clients/eventdemo.c |   13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/clients/eventdemo.c b/clients/eventdemo.c
> index daf3283..bc066be 100644
> --- a/clients/eventdemo.c
> +++ b/clients/eventdemo.c
> @@ -261,6 +261,7 @@ motion_handler(struct widget *widget, struct input *input, uint32_t time,
>  
>  /**
>   * \brief Create and initialise a new eventdemo window.
> + * The returned eventdemo instance should be destroyed using \c eventdemo_destroy().
>   * \param d associated display
>   */
>  static struct eventdemo *
> @@ -320,6 +321,14 @@ eventdemo_create(struct display *d)
>  	return e;
>  }
>  /**
> + * \brief Destroy eventdemo instance previously created by \c eventdemo_create().
> + * \param eventdemo eventdemo instance to destroy
> + */
> +static void eventdemo_destroy(struct eventdemo * eventdemo)
> +{

I think this needs to destroy also the window and the widget, no?

> +	free(eventdemo);
> +}
> +/**
>   * \brief command line options for eventdemo
>   */
>  static const struct weston_option eventdemo_options[] = {
> @@ -366,5 +375,9 @@ main(int argc, char *argv[])
>  
>  	display_run(d);
>  
> +	/* Release resources */
> +	display_destroy(d);
> +	eventdemo_destroy(e);

Would be more consistent to destroy the display last.

> +
>  	return 0;
>  }


Thanks,
pq


More information about the wayland-devel mailing list