GIOChannel reference counting



Dear all,

I would be grateful if anyone could tell me whether I need to unreference a GIOChannel in order to destroy it properly.

Here's what I'm currently doing:

1. I create a channel with g_io_channel_unix_new() from a socket. The docs state that the initial reference count will be 1.
2. I then add a watch on it with g_io_add_watch().
3. At a later date, I remove the watch with g_source_remove().
4. I want to destroy the channel and free all resources, so call g_io_channel_shutdown().

However, the docs for the shutdown function state that the channel will not be freed until the last reference is dropped using g_io_channel_unref(). Does this include the initial reference added on creation, or is that unreferenced by the shutdown function.

I.e., do I need to call g_io_channel_unref() myself to ensure things are really freed?

Thanks for any advice you can offer,
Richard.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]