[svn-commits] eliel: branch eliel/data_retrieval r183688 - /team/eliel/data_retrieval/main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Mar 23 07:18:52 CDT 2009


Author: eliel
Date: Mon Mar 23 07:18:48 2009
New Revision: 183688

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183688
Log:
Fix the way i was using refcounting... Now the unlinking process will depend on the node childrens.

Modified:
    team/eliel/data_retrieval/main/data.c

Modified: team/eliel/data_retrieval/main/data.c
URL: http://svn.digium.com/svn-view/asterisk/team/eliel/data_retrieval/main/data.c?view=diff&rev=183688&r1=183687&r2=183688
==============================================================================
--- team/eliel/data_retrieval/main/data.c (original)
+++ team/eliel/data_retrieval/main/data.c Mon Mar 23 07:18:48 2009
@@ -53,7 +53,7 @@
  */
 static ast_rwlock_t root_data_lock;
 
-/*! 
+/*!
  * \internal
  * \brief Common string hash function.
  */
@@ -171,8 +171,6 @@
 	}
 
 	ao2_link(parent, child);
-
-	ao2_ref(child, -1);
 
 	return child;
 }
@@ -234,12 +232,12 @@
 		data_nodes_release(child->children, rpath);
 	}
 
-	if (ao2_ref(child, 0) == 2) {
+	/* if this node is empty, unlink it. */
+	if (!ao2_container_count(child->children)) {
 		ao2_unlink(parent, child);
-		ao2_ref(child, -1);
-	} else {
-		ao2_ref(child, -2);
-	}
+	}
+
+	ao2_ref(child, -1);
 
 	return 0;
 }
@@ -275,6 +273,8 @@
 	if (rpath) {
 		ret = data_nodes_create(child->children, rpath);
 	}
+
+	ao2_ref(child, -1);
 
 	return ret ? ret : child;
 }




More information about the svn-commits mailing list