summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-04-28 17:59:07 +0200
committerThomas Haller <thaller@redhat.com>2015-04-28 18:25:43 +0200
commitb5beaef8fa19a85110582b3c4439daa49e567d85 (patch)
treef84fcc22c2deb954dc1894e7721396bc866ef52f /include
parentaf2c0ef7714c8a10ae9d211497f032dd5c76fcdb (diff)
downloadNetworkManager-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);
Diffstat (limited to 'include')
-rw-r--r--include/nm-utils-internal.h13
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