diff options
author | Thomas Haller <thaller@redhat.com> | 2015-04-28 17:59:07 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-04-28 18:25:43 +0200 |
commit | b5beaef8fa19a85110582b3c4439daa49e567d85 (patch) | |
tree | f84fcc22c2deb954dc1894e7721396bc866ef52f | |
parent | af2c0ef7714c8a10ae9d211497f032dd5c76fcdb (diff) | |
download | NetworkManager-b5beaef8fa19a85110582b3c4439daa49e567d85.tar.gz |
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);
-rw-r--r-- | include/nm-utils-internal.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/nm-utils-internal.h b/include/nm-utils-internal.h index 49991cfa0f..06d5d06357 100644 --- a/include/nm-utils-internal.h +++ b/include/nm-utils-internal.h @@ -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 |