[svn-commits] kpfleming: trunk r263208 - /trunk/main/astobj2.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Sun May 16 06:14:41 CDT 2010
Author: kpfleming
Date: Sun May 16 06:14:37 2010
New Revision: 263208
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=263208
Log:
Improve some very confusing structure names in astobj2.c
As pointed out by 'akshayb' on #asterisk-dev, the code here called a list of
bucket entries a 'bucket', and the entries within the bucket were called
'bucket_list'. This made the code very hard to understand without reading
all of it... so I've renamed 'bucket_list' to 'bucket_entry' to clarify the
purpose of the structure.
Modified:
trunk/main/astobj2.c
Modified: trunk/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/astobj2.c?view=diff&rev=263208&r1=263207&r2=263208
==============================================================================
--- trunk/main/astobj2.c (original)
+++ trunk/main/astobj2.c Sun May 16 06:14:37 2010
@@ -137,11 +137,11 @@
static int internal_ao2_ref(void *user_data, const int delta);
static struct ao2_container *internal_ao2_container_alloc(struct ao2_container *c, const uint n_buckets, ao2_hash_fn *hash_fn,
ao2_callback_fn *cmp_fn);
-static struct bucket_list *internal_ao2_link(struct ao2_container *c, void *user_data, const char *file, int line, const char *func);
+static struct bucket_entry *internal_ao2_link(struct ao2_container *c, void *user_data, const char *file, int line, const char *func);
static void *internal_ao2_callback(struct ao2_container *c,
const enum search_flags flags, void *cb_fn, void *arg, void *data, enum ao2_callback_type type,
char *tag, char *file, int line, const char *funcname);
-static void *internal_ao2_iterator_next(struct ao2_iterator *a, struct bucket_list **q);
+static void *internal_ao2_iterator_next(struct ao2_iterator *a, struct bucket_entry **q);
int __ao2_lock(void *user_data, const char *file, const char *func, int line, const char *var)
{
@@ -348,7 +348,7 @@
static void container_destruct_debug(void *c);
/* each bucket in the container is a tailq. */
-AST_LIST_HEAD_NOLOCK(bucket, bucket_list);
+AST_LIST_HEAD_NOLOCK(bucket, bucket_entry);
/*!
* A container; stores the hash and callback functions, information on
@@ -367,7 +367,7 @@
*
* \todo Linking and unlink objects is typically expensive, as it
* involves a malloc() of a small object which is very inefficient.
- * To optimize this, we allocate larger arrays of bucket_list's
+ * To optimize this, we allocate larger arrays of bucket_entry's
* when we run out of them, and then manage our own freelist.
* This will be more efficient as we can do the freelist management while
* we hold the lock (that we need anyways).
@@ -461,8 +461,8 @@
* used within a bucket.
* XXX \todo this should be private to the container code
*/
-struct bucket_list {
- AST_LIST_ENTRY(bucket_list) entry;
+struct bucket_entry {
+ AST_LIST_ENTRY(bucket_entry) entry;
int version;
struct astobj2 *astobj; /* pointer to internal data */
};
@@ -471,11 +471,11 @@
* link an object to a container
*/
-static struct bucket_list *internal_ao2_link(struct ao2_container *c, void *user_data, const char *file, int line, const char *func)
+static struct bucket_entry *internal_ao2_link(struct ao2_container *c, void *user_data, const char *file, int line, const char *func)
{
int i;
/* create a new list entry */
- struct bucket_list *p;
+ struct bucket_entry *p;
struct astobj2 *obj = INTERNAL_OBJ(user_data);
if (obj == NULL)
@@ -503,7 +503,7 @@
void *__ao2_link_debug(struct ao2_container *c, void *user_data, char *tag, char *file, int line, const char *funcname)
{
- struct bucket_list *p = internal_ao2_link(c, user_data, file, line, funcname);
+ struct bucket_entry *p = internal_ao2_link(c, user_data, file, line, funcname);
if (p) {
__ao2_ref_debug(user_data, +1, tag, file, line, funcname);
@@ -514,7 +514,7 @@
void *__ao2_link(struct ao2_container *c, void *user_data)
{
- struct bucket_list *p = internal_ao2_link(c, user_data, __FILE__, __LINE__, __PRETTY_FUNCTION__);
+ struct bucket_entry *p = internal_ao2_link(c, user_data, __FILE__, __LINE__, __PRETTY_FUNCTION__);
if (p) {
__ao2_ref(user_data, +1);
@@ -533,7 +533,7 @@
/*
* Unlink an object from the container
- * and destroy the associated * ao2_bucket_list structure.
+ * and destroy the associated * bucket_entry structure.
*/
void *__ao2_unlink_debug(struct ao2_container *c, void *user_data, char *tag,
char *file, int line, const char *funcname)
@@ -658,7 +658,7 @@
for (; i < last ; i++) {
/* scan the list with prev-cur pointers */
- struct bucket_list *cur;
+ struct bucket_entry *cur;
AST_LIST_TRAVERSE_SAFE_BEGIN(&c->buckets[i], cur, entry) {
int match = (CMP_MATCH | CMP_STOP);
@@ -823,10 +823,10 @@
/*
* move to the next element in the container.
*/
-static void *internal_ao2_iterator_next(struct ao2_iterator *a, struct bucket_list **q)
+static void *internal_ao2_iterator_next(struct ao2_iterator *a, struct bucket_entry **q)
{
int lim;
- struct bucket_list *p = NULL;
+ struct bucket_entry *p = NULL;
void *ret = NULL;
*q = NULL;
@@ -892,7 +892,7 @@
void *__ao2_iterator_next_debug(struct ao2_iterator *a, char *tag, char *file, int line, const char *funcname)
{
- struct bucket_list *p;
+ struct bucket_entry *p;
void *ret = NULL;
ret = internal_ao2_iterator_next(a, &p);
@@ -910,7 +910,7 @@
void *__ao2_iterator_next(struct ao2_iterator *a)
{
- struct bucket_list *p = NULL;
+ struct bucket_entry *p = NULL;
void *ret = NULL;
ret = internal_ao2_iterator_next(a, &p);
@@ -949,7 +949,7 @@
__ao2_callback(c, OBJ_UNLINK, cd_cb, NULL);
for (i = 0; i < c->n_buckets; i++) {
- struct bucket_list *current;
+ struct bucket_entry *current;
while ((current = AST_LIST_REMOVE_HEAD(&c->buckets[i], entry))) {
ast_free(current);
@@ -969,7 +969,7 @@
__ao2_callback_debug(c, OBJ_UNLINK, cd_cb_debug, NULL, "container_destruct_debug called", __FILE__, __LINE__, __PRETTY_FUNCTION__);
for (i = 0; i < c->n_buckets; i++) {
- struct bucket_list *current;
+ struct bucket_entry *current;
while ((current = AST_LIST_REMOVE_HEAD(&c->buckets[i], entry))) {
ast_free(current);
More information about the svn-commits
mailing list