Re: Correct way to deallocate an unix signal source
- 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
- Date: Mon, 18 Mar 2019 13:51:25 +0000
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]