[PATCH memleak service 1/3] ipconfig: add debugging to ref counting functions

Jukka Rissanen jukka.rissanen at nokia.com
Wed Jan 5 05:14:11 PST 2011


---
 src/ipconfig.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 690b51e..b5dc98f 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -915,6 +915,9 @@ struct connman_ipconfig *connman_ipconfig_create(int index,
  */
 struct connman_ipconfig *connman_ipconfig_ref(struct connman_ipconfig *ipconfig)
 {
+	DBG("ipconfig %p refcount %d", ipconfig,
+				g_atomic_int_get(&ipconfig->refcount) + 1);
+
 	g_atomic_int_inc(&ipconfig->refcount);
 
 	return ipconfig;
@@ -928,8 +931,13 @@ struct connman_ipconfig *connman_ipconfig_ref(struct connman_ipconfig *ipconfig)
  */
 void connman_ipconfig_unref(struct connman_ipconfig *ipconfig)
 {
-	if (ipconfig &&
-		g_atomic_int_dec_and_test(&ipconfig->refcount) == TRUE) {
+	if (ipconfig == NULL)
+		return;
+
+	DBG("ipconfig %p refcount %d", ipconfig,
+			g_atomic_int_get(&ipconfig->refcount) - 1);
+
+	if (g_atomic_int_dec_and_test(&ipconfig->refcount) == TRUE) {
 		__connman_ipconfig_disable(ipconfig);
 
 		connman_ipconfig_set_ops(ipconfig, NULL);
-- 
1.7.0.4




More information about the connman mailing list