[PATCH wayland] Add a destroy signal to the wl_event_loop object.
David Herrmann
dh.herrmann at googlemail.com
Wed Jan 23 05:08:15 PST 2013
Hi Jason
On Sat, Jan 12, 2013 at 4:01 AM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> Add a destroy signal to the wl_event_loop object.
>
> ---
> Again, this helps me prevent memory leaks.
>
> This time I used tabs ;-)
>
> src/event-loop.c | 21 ++++++++++++++++++
> src/wayland-server.h | 6 ++++++
> tests/event-loop-test.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 84 insertions(+)
>
> diff --git a/src/event-loop.c b/src/event-loop.c
> index 8db9c7c..25e8f9c 100644
> --- a/src/event-loop.c
> +++ b/src/event-loop.c
> @@ -43,6 +43,8 @@ struct wl_event_loop {
> struct wl_list check_list;
> struct wl_list idle_list;
> struct wl_list destroy_list;
> +
> + struct wl_signal destroy_signal;
> };
>
> struct wl_event_source_interface {
> @@ -357,12 +359,16 @@ wl_event_loop_create(void)
> wl_list_init(&loop->idle_list);
> wl_list_init(&loop->destroy_list);
>
> + wl_signal_init(&loop->destroy_signal);
> +
> return loop;
> }
>
> WL_EXPORT void
> wl_event_loop_destroy(struct wl_event_loop *loop)
> {
> + wl_signal_emit(&loop->destroy_signal, loop);
> +
> wl_event_loop_process_destroy_list(loop);
> close(loop->epoll_fd);
> free(loop);
> @@ -429,3 +435,18 @@ wl_event_loop_get_fd(struct wl_event_loop *loop)
> {
> return loop->epoll_fd;
> }
> +
> +WL_EXPORT void
> +wl_event_loop_add_destroy_listener(struct wl_event_loop *loop,
> + struct wl_listener *listener)
> +{
> + wl_signal_add(&loop->destroy_signal, listener);
> +}
> +
> +WL_EXPORT struct wl_listener *
> +wl_event_loop_get_destroy_listener(struct wl_event_loop *loop,
> + wl_notify_func_t notify)
> +{
> + wl_signal_get(&loop->destroy_signal, notify);
You forgot to return the result here. I will send a fixup for that.
Regards
David
More information about the wayland-devel
mailing list