diff options
author | Thomas Haller <thaller@redhat.com> | 2016-03-12 15:38:53 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-03-13 12:31:04 +0100 |
commit | 4a00bcf5a6a8ad37d5bebd13dc640992cc104c18 (patch) | |
tree | b26e05ba9f7c5746aea64e6683721d2c298ba2d1 | |
parent | 0f6febc6fbeafde62e6e0a8c12f57204d94166fb (diff) | |
download | NetworkManager-4a00bcf5a6a8ad37d5bebd13dc640992cc104c18.tar.gz |
shared: add nm_g_object_ref() and nm_g_object_unref() function
-rw-r--r-- | shared/nm-macros-internal.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h index dafce87795..1f638bab18 100644 --- a/shared/nm-macros-internal.h +++ b/shared/nm-macros-internal.h @@ -313,6 +313,26 @@ _notify (obj_type *obj, _PropertyEnums prop) \ /*****************************************************************************/ +static inline gpointer +nm_g_object_ref (gpointer obj) +{ + /* g_object_ref() doesn't accept NULL. */ + if (obj) + g_object_ref (obj); + return obj; +} + +static inline void +nm_g_object_unref (gpointer obj) +{ + /* g_object_unref() doesn't accept NULL. Usully, we workaround that + * by using g_clear_object(), but sometimes that is not convinient + * (for example as as destroy function for a hash table that can contain + * NULL values). */ + if (obj) + g_object_unref (obj); +} + static inline gboolean nm_clear_g_source (guint *id) { |