From b5beaef8fa19a85110582b3c4439daa49e567d85 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 28 Apr 2015 17:59:07 +0200 Subject: 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); --- include/nm-utils-internal.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') 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 -- cgit v1.2.1