utils: add nm_clear_g_source() helper

Utility function to simplify the following common code:

    if (priv->timeout_id) {
        g_source_remove (priv->timeout_id);
        priv->timeout_id = 0;
    }

to

    nm_clear_g_source (&priv->timeout_id);

(cherry picked from commit b5beaef8fa)
This commit is contained in:
Thomas Haller 2015-04-28 17:59:07 +02:00
parent 7dfd7801e9
commit 7028c8a53f

View file

@ -160,4 +160,17 @@ NM_DEFINE_SINGLETON_DESTRUCTOR(TYPE)
/*****************************************************************************/
static inline gboolean
nm_clear_g_source (guint *id)
{
if (id && *id) {
g_source_remove (*id);
*id = 0;
return TRUE;
}
return FALSE;
}
/*****************************************************************************/
#endif