Verified Commit c1dab570 authored by Thomas Haller's avatar Thomas Haller
Browse files

glib-aux/trivial: clearify code comment in nm_g_source_destroy_and_unref()

parent 25aa6c05
Pipeline #488034 passed with stages
in 39 minutes and 5 seconds
...@@ -1658,15 +1658,16 @@ nm_g_source_destroy_and_unref(GSource *source) ...@@ -1658,15 +1658,16 @@ nm_g_source_destroy_and_unref(GSource *source)
* will destroy the user-data of the callback right away (and not only * will destroy the user-data of the callback right away (and not only
* during the last g_source_unref()). * during the last g_source_unref()).
* *
* It also means, that if the user data itself has the reference to the * This means for example, if the user data itself has the reference to the
* source, then this will lead to crash: * source, then the following would lead to a crash:
* *
* g_source_destroy(user_data->my_source); * g_source_destroy(user_data->my_source);
* // ups, user_data was destroyed (if source was attached). * // ups, user_data was destroyed (if source was attached).
* g_source_unref(user_data->my_source); * g_source_unref(user_data->my_source);
* *
* nm_g_source_destroy_and_unref() and nm_clear_g_source_inst() does not * nm_g_source_destroy_and_unref(user_data->my_source) and nm_clear_g_source_inst(&user_data->my_source)
* suffer from this problem. */ * does not have this problem (of course, afterwards, user_data would be a dangling
* pointer). */
g_source_destroy(source); g_source_destroy(source);
g_source_unref(source); g_source_unref(source);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment