Re: Correct way to deallocate an unix signal source
- From: Enrico Mioso <mrkiko rs gmail com>
- To: Philip Withnall <withnall endlessm com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Correct way to deallocate an unix signal source
- Date: Mon, 18 Mar 2019 15:07:18 +0100 (CET)
That's great! Thanks! Yeah, I'll keep it on my mind. I currently choose to depend on GLib 2.58 to do
something like:
g_source_set_callback(lctx->logwatcher, G_SOURCE_FUNC(agh_ubus_logstream_channel_io), lctx, NULL);
so there should be no issues in case.
Thank again!!
Enrico
On Mon, 18 Mar 2019, Philip Withnall wrote:
Date: Mon, 18 Mar 2019 14:51:25
From: Philip Withnall <withnall endlessm com>
To: Enrico Mioso <mrkiko rs gmail com>
Cc: gtk-app-devel-list gnome org
Subject: Re: Correct way to deallocate an unix signal source
On Mon, 2019-03-18 at 14:38 +0100, Enrico Mioso wrote:
Regarding the code, at exit I do the following:
if (my_state->mainloop) {
g_main_loop_unref(my_state->mainloop);
my_state->mainloop = NULL;
}
if (my_state->ctx) {
g_main_context_unref(my_state->ctx);
my_state->ctx = NULL;
}
That looks fine. If you depend on GLib ≥ 2.34, you can instead do:
g_clear_pointer (&my_state->mainloop, g_main_loop_unref);
g_clear_pointer (&my_state->ctx, g_main_context_unref);
which is equivalent, but simplifies things a bit.
Philip
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]