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);
This commit is contained in:
Thomas Haller 2015-04-28 17:59:07 +02:00
parent af2c0ef771
commit b5beaef8fa

View file

@ -168,4 +168,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