[asterisk-commits] rmudgett: branch rmudgett/ao2_enhancements r370532 - in /team/rmudgett/ao2_en...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 27 18:36:03 CDT 2012


Author: rmudgett
Date: Fri Jul 27 18:35:58 2012
New Revision: 370532

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=370532
Log:
Some tweaks and fixed list container allocation functions.

Modified:
    team/rmudgett/ao2_enhancements/include/asterisk/astobj2.h
    team/rmudgett/ao2_enhancements/main/astobj2.c

Modified: team/rmudgett/ao2_enhancements/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ao2_enhancements/include/asterisk/astobj2.h?view=diff&rev=370532&r1=370531&r2=370532
==============================================================================
--- team/rmudgett/ao2_enhancements/include/asterisk/astobj2.h (original)
+++ team/rmudgett/ao2_enhancements/include/asterisk/astobj2.h Fri Jul 27 18:35:58 2012
@@ -969,8 +969,8 @@
 	AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE = (3 << 1),
 };
 
-/*! \brief
- * Type of a generic callback function
+/*!
+ * \brief Type of a generic callback function
  * \param obj  pointer to the (user-defined part) of an object.
  * \param arg callback argument from ao2_callback()
  * \param flags flags from ao2_callback()
@@ -983,8 +983,8 @@
 /*! \brief A common ao2_callback is one that matches by address. */
 int ao2_match_by_addr(void *obj, void *arg, int flags);
 
-/*! \brief
- * Type of a generic callback function
+/*!
+ * \brief Type of a generic callback function
  * \param obj pointer to the (user-defined part) of an object.
  * \param arg callback argument from ao2_callback()
  * \param data arbitrary data from ao2_callback()

Modified: team/rmudgett/ao2_enhancements/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ao2_enhancements/main/astobj2.c?view=diff&rev=370532&r1=370531&r2=370532
==============================================================================
--- team/rmudgett/ao2_enhancements/main/astobj2.c (original)
+++ team/rmudgett/ao2_enhancements/main/astobj2.c Fri Jul 27 18:35:58 2012
@@ -531,6 +531,13 @@
 int __ao2_ref(void *user_data, int delta)
 {
 	return internal_ao2_ref(user_data, delta, __FILE__, __LINE__, __FUNCTION__);
+}
+
+void ao2_cleanup(void *obj)
+{
+	if (obj) {
+		ao2_ref(obj, -1);
+	}
 }
 
 static void *internal_ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned int options, const char *file, int line, const char *func)
@@ -1048,6 +1055,13 @@
 	}
 }
 
+void ao2_iterator_cleanup(struct ao2_iterator *iter)
+{
+	if (iter) {
+		ao2_iterator_destroy(iter);
+	}
+}
+
 /*
  * move to the next element in the container.
  */
@@ -1797,10 +1811,12 @@
 {
 	/* XXX maybe consistency check on arguments ? */
 	/* compute the container size */
-	const unsigned int num_buckets = hash_fn ? n_buckets : 1;
-	size_t container_size = sizeof(struct ao2_container_hash)
-		+ num_buckets * sizeof(struct bucket);
+	unsigned int num_buckets;
+	size_t container_size;
 	struct ao2_container_hash *self;
+
+	num_buckets = hash_fn ? n_buckets : 1;
+	container_size = sizeof(struct ao2_container_hash) + num_buckets * sizeof(struct bucket);
 
 	self = __ao2_alloc(container_size, container_destruct, ao2_options);
 	return hash_ao2_container_init(self, container_options, num_buckets,
@@ -1830,7 +1846,7 @@
 struct ao2_container *__ao2_container_alloc_list(unsigned int ao2_options,
 	unsigned int container_options, ao2_sort_fn *sort_fn, ao2_callback_fn *cmp_fn)
 {
-	return __ao2_container_alloc_hash(ao2_options, container_options, 1, NULL, NULL,
+	return __ao2_container_alloc_hash(ao2_options, container_options, 1, NULL, sort_fn,
 		cmp_fn);
 }
 
@@ -1838,8 +1854,8 @@
 	unsigned int container_options, ao2_sort_fn *sort_fn, ao2_callback_fn *cmp_fn,
 	const char *tag, const char *file, int line, const char *func, int ref_debug)
 {
-	return __ao2_container_alloc_hash_debug(ao2_options, container_options, 1, NULL, NULL,
-		cmp_fn, tag, file, line, func, ref_debug);
+	return __ao2_container_alloc_hash_debug(ao2_options, container_options, 1, NULL,
+		sort_fn, cmp_fn, tag, file, line, func, ref_debug);
 }
 
 struct ao2_container *__ao2_container_alloc(unsigned int options,
@@ -1857,20 +1873,6 @@
 }
 
 /*! BUGBUG need to add red-black tree container support */
-
-void ao2_cleanup(void *obj)
-{
-	if (obj) {
-		ao2_ref(obj, -1);
-	}
-}
-
-void ao2_iterator_cleanup(struct ao2_iterator *iter)
-{
-	if (iter) {
-		ao2_iterator_destroy(iter);
-	}
-}
 
 #ifdef AO2_DEBUG
 static int print_cb(void *obj, void *arg, int flag)




More information about the asterisk-commits mailing list