[svn-commits] akshayb: branch akshayb/ao2_containers r265226 - /team/akshayb/ao2_containers...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat May 22 14:50:16 CDT 2010


Author: akshayb
Date: Sat May 22 14:50:15 2010
New Revision: 265226

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=265226
Log:
Committed new Definition of ao2_container; Little work on alloc funtion doen

Modified:
    team/akshayb/ao2_containers/main/astobj2.c

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=265226&r1=265225&r2=265226
==============================================================================
--- team/akshayb/ao2_containers/main/astobj2.c (original)
+++ team/akshayb/ao2_containers/main/astobj2.c Sat May 22 14:50:15 2010
@@ -372,17 +372,40 @@
  * This will be more efficient as we can do the freelist management while
  * we hold the lock (that we need anyways).
  */
+
+struct ao2_container_core {
+	ao2_callback_fn *cmp_fn;
+	/*! Number of elements in the container */
+	int elements;
+	/*! described above */
+	int version;
+};
+
+struct ao2_container {
+	ao2_contaniner_core core;
+	ao2_hash_fn *hash_fn;
+	ao2_link_fn *link_fn;
+	ao2_unlink_fn *unlink_fn;
+	int n_buckets;
+	/*! variable size */
+	struct bucket buckets[0];
+};
+
+
+	
+//Left Old code for reference. Has to be removed once work done
+
+/*
 struct ao2_container {
 	ao2_hash_fn *hash_fn;
 	ao2_callback_fn *cmp_fn;
 	int n_buckets;
-	/*! Number of elements in the container */
 	int elements;
-	/*! described above */
 	int version;
-	/*! variable size */
 	struct bucket buckets[0];
 };
+
+*/
  
 /*!
  * \brief always zero hash function
@@ -399,21 +422,21 @@
 }
 
 /*
- * A container is just an object, after all!
- */
-static struct ao2_container *internal_ao2_container_alloc(struct ao2_container *c, const unsigned int n_buckets, ao2_hash_fn *hash_fn,
-							  ao2_callback_fn *cmp_fn)
-{
-	/* XXX maybe consistency check on arguments ? */
-	/* compute the container size */
-
+ * Constructor definition to initialize ao2_container. Care Has to be taken 
+ * on addition of new parameters of in the container structure.
+ */
+
+static struct ao2_container *internal_ao2_container_alloc(struct ao2_container *c, const unsigned int n_buckets, ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn, ao2_link_fn *link_fn, ao2_unlink_fn *unlink_fn)
+{
 	if (!c)
 		return NULL;
 	
-	c->version = 1;	/* 0 is a reserved value here */
+	c->core.version = 1; /* 0 is a reserved value here */
 	c->n_buckets = hash_fn ? n_buckets : 1;
 	c->hash_fn = hash_fn ? hash_fn : hash_zero;
-	c->cmp_fn = cmp_fn;
+	c->core->cmp_fn = cmp_fn;
+	c->link_fn = link_fn;
+	c->unlink_fn = unlink_fn;
 
 #ifdef AO2_DEBUG
 	ast_atomic_fetchadd_int(&ao2.total_containers, 1);




More information about the svn-commits mailing list