diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-06-01 12:04:10 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-06-01 12:37:16 +0100 |
commit | 76b009647855df20788ffb1990c4de8798ee5f82 (patch) | |
tree | 234ed68e805355c7f2b1a028a1bec18f3250de95 /telepathy-glib/util.h | |
parent | c119cd79de81c0069343c61c1dcffd0fd64f7918 (diff) | |
download | telepathy-glib-76b009647855df20788ffb1990c4de8798ee5f82.tar.gz |
Add tp_clear_object, tp_clear_pointer macros
Diffstat (limited to 'telepathy-glib/util.h')
-rw-r--r-- | telepathy-glib/util.h | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/telepathy-glib/util.h b/telepathy-glib/util.h index 8c8aafedc..b959e36fe 100644 --- a/telepathy-glib/util.h +++ b/telepathy-glib/util.h @@ -1,9 +1,8 @@ /* * util.h - Headers for telepathy-glib utility functions * - * Copyright (C) 2006-2007 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright (C) 2006-2007 Nokia Corporation - * @author Robert McQueen <robert.mcqueen@collabora.co.uk> + * Copyright © 2006-2010 Collabora Ltd. <http://www.collabora.co.uk/> + * Copyright © 2006-2008 Nokia Corporation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -107,6 +106,38 @@ gpointer tp_weak_ref_get_user_data (TpWeakRef *self) G_GNUC_WARN_UNUSED_RESULT; gpointer tp_weak_ref_dup_object (TpWeakRef *self) G_GNUC_WARN_UNUSED_RESULT; void tp_weak_ref_destroy (TpWeakRef *self); +#define tp_clear_pointer(pp, destroy) \ + G_STMT_START \ + { \ + if (pp != NULL) \ + { \ + gpointer _tp_clear_pointer_tmp = *(pp); \ + \ + *(pp) = NULL; \ + \ + if (_tp_clear_pointer_tmp != NULL) \ + (destroy) (_tp_clear_pointer_tmp); \ + } \ + } \ + G_STMT_END + +#define tp_clear_object(op) tp_clear_pointer ((op), g_object_unref) + +#define tp_clear_boxed(gtype, pp) \ + G_STMT_START \ + { \ + if (pp != NULL) \ + { \ + gpointer _tp_clear_boxed_tmp = *(pp); \ + \ + *(pp) = NULL; \ + \ + if (_tp_clear_boxed_tmp != NULL) \ + g_boxed_free (gtype, _tp_clear_boxed_tmp); \ + } \ + } \ + G_STMT_END + G_END_DECLS #undef __TP_IN_UTIL_H__ |