[telepathy-mission-control/master] mcd_debug_[un]ref: deprecate, and stop overriding g_object_[un]ref
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Sep 10 11:12:50 PDT 2009
The output from these turns out not to be as useful as you might think:
about half the refs and unrefs happen somewhere in the bowels of GObject
(e.g. g_value_dup_object creates a ref without calling mcd_debug_ref),
so the debug log, while verbose, doesn't actually provide enough
information to locate leaks.
refdbg is what I actually ended up using to find leaks during 5.1
development; it works considerably better in practice, and doesn't require
source code modification (or namespace pollution).
---
.../libmissioncontrol-server/tmpl/mcd-debug.sgml | 16 -----------
src/mcd-debug.c | 27 ++++++--------------
src/mcd-debug.h | 12 +++------
3 files changed, 12 insertions(+), 43 deletions(-)
diff --git a/doc/reference/libmissioncontrol-server/tmpl/mcd-debug.sgml b/doc/reference/libmissioncontrol-server/tmpl/mcd-debug.sgml
index 2b499d8..93dc930 100644
--- a/doc/reference/libmissioncontrol-server/tmpl/mcd-debug.sgml
+++ b/doc/reference/libmissioncontrol-server/tmpl/mcd-debug.sgml
@@ -17,22 +17,6 @@ mcd-debug
<!-- ##### SECTION Stability_Level ##### -->
-<!-- ##### MACRO g_object_ref ##### -->
-<para>
-
-</para>
-
- at obj:
-
-
-<!-- ##### MACRO g_object_unref ##### -->
-<para>
-
-</para>
-
- at obj:
-
-
<!-- ##### FUNCTION mcd_debug_init ##### -->
<para>
diff --git a/src/mcd-debug.c b/src/mcd-debug.c
index 3c4e9f9..8130b70 100644
--- a/src/mcd-debug.c
+++ b/src/mcd-debug.c
@@ -44,30 +44,19 @@
gint mcd_debug_level = 0;
gpointer
-mcd_debug_ref (gpointer obj, const gchar *filename, gint linenum)
+mcd_debug_ref (gpointer obj,
+ const gchar *filename G_GNUC_UNUSED,
+ gint linenum G_GNUC_UNUSED)
{
- /* Function reference untouchable by macro processing */
- gpointer (*untouchable_ref) (gpointer object);
-
- untouchable_ref = g_object_ref;
- if (mcd_debug_level >= 2)
- g_debug ("[%s:%d]: Referencing (%d) object %p of type %s",
- filename, linenum, G_OBJECT (obj)->ref_count,
- obj, G_OBJECT_TYPE_NAME(obj));
- return untouchable_ref (obj);
+ return g_object_ref (obj);
}
void
-mcd_debug_unref (gpointer obj, const gchar *filename, gint linenum)
+mcd_debug_unref (gpointer obj,
+ const gchar *filename G_GNUC_UNUSED,
+ gint linenum G_GNUC_UNUSED)
{
- void (*untouchable_unref) (gpointer object);
-
- untouchable_unref = g_object_unref;
- if (mcd_debug_level >= 2)
- g_debug ("[%s:%d]: Unreferencing (%d) object %p of type %s",
- filename, linenum, G_OBJECT (obj)->ref_count, obj,
- G_OBJECT_TYPE_NAME(obj));
- untouchable_unref (obj);
+ g_object_unref (obj);
}
static void
diff --git a/src/mcd-debug.h b/src/mcd-debug.h
index 25d575e..99bfcdb 100644
--- a/src/mcd-debug.h
+++ b/src/mcd-debug.h
@@ -42,12 +42,6 @@ G_BEGIN_DECLS
g_debug ("%s: " format, G_STRFUNC, ##__VA_ARGS__); \
} G_STMT_END
-/* reference count debugging */
-#ifndef g_object_ref
-#define g_object_ref(obj) (mcd_debug_ref (obj, __FILE__, __LINE__))
-#define g_object_unref(obj) (mcd_debug_unref (obj, __FILE__, __LINE__))
-#endif
-
#else /* !defined ENABLE_DEBUG */
#define DEBUGGING (0)
@@ -65,8 +59,10 @@ static inline gint _mcd_debug_get_level (void)
return mcd_debug_level;
}
-gpointer mcd_debug_ref (gpointer obj, const gchar *filename, gint linenum);
-void mcd_debug_unref (gpointer obj, const gchar *filename, gint linenum);
+gpointer mcd_debug_ref (gpointer obj, const gchar *filename, gint linenum)
+ G_GNUC_DEPRECATED;
+void mcd_debug_unref (gpointer obj, const gchar *filename, gint linenum)
+ G_GNUC_DEPRECATED;
void mcd_debug_print_tree (gpointer obj);
--
1.5.6.5
More information about the telepathy-commits
mailing list