[asterisk-commits] akshayb: branch akshayb/ao2_containers r265837 - in /team/akshayb/ao2_contain...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed May 26 02:43:32 CDT 2010
Author: akshayb
Date: Wed May 26 02:43:30 2010
New Revision: 265837
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=265837
Log:
Day 2 commit
Modified:
team/akshayb/ao2_containers/include/asterisk/astobj2.h
team/akshayb/ao2_containers/main/astobj2.c
team/akshayb/ao2_containers/main/astobj2_hash.c
Modified: team/akshayb/ao2_containers/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/team/akshayb/ao2_containers/include/asterisk/astobj2.h?view=diff&rev=265837&r1=265836&r2=265837
==============================================================================
--- team/akshayb/ao2_containers/include/asterisk/astobj2.h (original)
+++ team/akshayb/ao2_containers/include/asterisk/astobj2.h Wed May 26 02:43:30 2010
@@ -778,6 +778,7 @@
*/
#ifdef REF_DEBUG
+//Definition of ao2_link remains here.
#define ao2_t_link(arg1, arg2, arg3) __ao2_link_debug((arg1), (arg2), (arg3), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_link(arg1, arg2) __ao2_link_debug((arg1), (arg2), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
Modified: team/akshayb/ao2_containers/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/akshayb/ao2_containers/main/astobj2.c?view=diff&rev=265837&r1=265836&r2=265837
==============================================================================
--- team/akshayb/ao2_containers/main/astobj2.c (original)
+++ team/akshayb/ao2_containers/main/astobj2.c Wed May 26 02:43:30 2010
@@ -421,8 +421,9 @@
* This is basically used when we want to have a container that is
* a simple linked list.
*
- * \returns 0
- */
+ * returns 0
+ */
+//hash_zero goes to var
static int hash_zero(const void *user_obj, const int flags)
{
return 0;
@@ -477,10 +478,11 @@
{
/* XXX maybe consistency check on arguments ? */
/* compute the container size */
-
+ //Have to search location for this thing.
const unsigned int num_buckets = hash_fn ? n_buckets : 1;
/* replace this size callculation by a function that is to be supplied by the writter as, buckets is not common in btree and other data structures. This has to be done when writing code for btree part. */
- size_t container_size = sizeof(struct ao2_container) + num_buckets * sizeof(struct bucket);
+ //size_t container_size = sizeof(struct ao2_container) + num_buckets * sizeof(struct bucket);
+ size_t container_size = get_container_size(num_buckets);
struct ao2_container *c = __ao2_alloc(container_size, container_destruct);
return internal_ao2_container_alloc(c, num_buckets, hash_fn, cmp_fn, link_fn, unlink_fn);
@@ -491,7 +493,7 @@
*/
int ao2_container_count(struct ao2_container *c)
{
- return c->elements;
+ return c->core.elements;
}
/*!
@@ -526,7 +528,7 @@
if (!p)
return NULL;
- i = abs(c->hash_fn(user_data, OBJ_POINTER));
+ i = abs(c->var.hash_fn(user_data, OBJ_POINTER));
ao2_lock(c);
i %= c->n_buckets;
Modified: team/akshayb/ao2_containers/main/astobj2_hash.c
URL: http://svnview.digium.com/svn/asterisk/team/akshayb/ao2_containers/main/astobj2_hash.c?view=diff&rev=265837&r1=265836&r2=265837
==============================================================================
--- team/akshayb/ao2_containers/main/astobj2_hash.c (original)
+++ team/akshayb/ao2_containers/main/astobj2_hash.c Wed May 26 02:43:30 2010
@@ -6,3 +6,12 @@
c->var.hash_fn = hash_fn;
c->var.n_buckets = n_buckets;
}
+
+//This funtion calculates the size of ao2_container. Just replace the code in case of other containers:
+
+size_t get_container_size (const unsigned int num_buckets)
+{
+ return (sizeof(struct ao2_container) + num_buckets * sizeof(struct bucket));
+}
+
+
More information about the asterisk-commits
mailing list