[asterisk-commits] mmichelson: branch mmichelson/ao2_containers r141994 - /team/mmichelson/ao2_c...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 9 02:14:56 CDT 2008
Author: mmichelson
Date: Tue Sep 9 02:14:56 2008
New Revision: 141994
URL: http://svn.digium.com/view/asterisk?view=rev&rev=141994
Log:
Fix the rest of astobj2_linkedlist to use the
proper types. Add ast_assert calls as a sanity
check to be sure that all the private data
structures that we assume to be there actually
are.
Modified:
team/mmichelson/ao2_containers/main/astobj2_hashtable.c
team/mmichelson/ao2_containers/main/astobj2_linkedlist.c
team/mmichelson/ao2_containers/main/astobj2_skiplist.c
Modified: team/mmichelson/ao2_containers/main/astobj2_hashtable.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/ao2_containers/main/astobj2_hashtable.c?view=diff&rev=141994&r1=141993&r2=141994
==============================================================================
--- team/mmichelson/ao2_containers/main/astobj2_hashtable.c (original)
+++ team/mmichelson/ao2_containers/main/astobj2_hashtable.c Tue Sep 9 02:14:56 2008
@@ -95,6 +95,8 @@
int bucket_number;
struct hashtable_pvt *hash_pvt = c->private;
+ ast_assert(hast_pvt);
+
if (!(bl = ast_calloc(1, sizeof(*bl)))) {
return NULL;
}
@@ -114,6 +116,8 @@
void *ret = NULL;
struct hashtable_pvt *hash_pvt = c->private;
+ ast_assert(hash_pvt);
+
/*
* XXX this can be optimized.
* If we have a hash function and lookup by pointer,
@@ -192,6 +196,7 @@
void *ret = NULL;
struct hashtable_pvt *hash_pvt = a->c->private;
+ ast_assert(hash_pvt);
/* optimization. If the container is unchanged and
* we have a pointer, try follow it
*/
@@ -235,6 +240,9 @@
{
struct hashtable_pvt *hash_pvt = c->private;
int i;
+
+ ast_assert(hash_pvt);
+
for (i = 0; i < hash_pvt->n_buckets; i++) {
struct bucket_list *current;
Modified: team/mmichelson/ao2_containers/main/astobj2_linkedlist.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/ao2_containers/main/astobj2_linkedlist.c?view=diff&rev=141994&r1=141993&r2=141994
==============================================================================
--- team/mmichelson/ao2_containers/main/astobj2_linkedlist.c (original)
+++ team/mmichelson/ao2_containers/main/astobj2_linkedlist.c Tue Sep 9 02:14:56 2008
@@ -68,6 +68,8 @@
struct list_item *item = ast_calloc(1, sizeof(*item));
struct linkedlist_pvt *list_pvt = c->private;
+ ast_assert(list_pvt);
+
if (!item) {
return NULL;
}
@@ -85,11 +87,13 @@
static void *linkedlist_callback(struct ao2_container *c, const enum search_flags flags, ao2_callback_fn *cb_fn, void *arg)
{
- struct the_list *list = c->private;
+ struct linkedlist_pvt *list_pvt = c->private;
struct list_item *item;
void *ret = NULL;
- AST_LIST_TRAVERSE_SAFE_BEGIN(list, item, entry) {
+ ast_assert(list_pvt);
+
+ AST_LIST_TRAVERSE_SAFE_BEGIN(list_pvt->the_list, item, entry) {
int match = cb_fn(EXTERNAL_OBJ(item->astobj), arg, flags) & (CMP_MATCH | CMP_STOP);
if (match == 0) {
@@ -123,9 +127,11 @@
static void *linkedlist_iterator_next_back(struct ao2_iterator *a)
{
- struct the_list *list = a->c->private;
+ struct linkedlist_pvt *list_pvt = a->c->private;
struct list_item *item;
void* ret = NULL;
+
+ ast_assert(list_pvt);
if (a->c->version == a->c_version && (item = a->obj)) {
if ((item = AST_LIST_NEXT(item, entry))) {
@@ -134,7 +140,7 @@
a->obj = NULL;
}
- AST_LIST_TRAVERSE(list, item, entry) {
+ AST_LIST_TRAVERSE(list_pvt->the_list, item, entry) {
if (list_pvt->direction == AO2_LINKEDLIST_BACK && item->version > a->version) {
goto found;
} else if (list_pvt->direction == AO2_LINKEDLIST_FRONT && item->version < a->version) {
@@ -155,10 +161,12 @@
static void linkedlist_destroy(struct ao2_container *c)
{
- struct the_list *list = c->private;
+ struct linkedlist_pvt *list_pvt = c->private;
struct list_item *item;
- while ((item = AST_LIST_REMOVE_HEAD(list, entry))) {
+ ast_assert(list_pvt);
+
+ while ((item = AST_LIST_REMOVE_HEAD(list_pvt->the_list, entry))) {
ast_free(item);
}
}
Modified: team/mmichelson/ao2_containers/main/astobj2_skiplist.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/ao2_containers/main/astobj2_skiplist.c?view=diff&rev=141994&r1=141993&r2=141994
==============================================================================
--- team/mmichelson/ao2_containers/main/astobj2_skiplist.c (original)
+++ team/mmichelson/ao2_containers/main/astobj2_skiplist.c Tue Sep 9 02:14:56 2008
@@ -93,6 +93,8 @@
struct list_item *forward;
int i;
int level = random_level(skip_pvt->num_levels);
+
+ ast_assert(skip_pvt);
if (!(item = ast_calloc(1, sizeof(*item) + level * sizeof(struct list_item *)))) {
return NULL;
@@ -147,6 +149,8 @@
void *ret = NULL;
int i;
+ ast_assert(skip_pvt);
+
/*XXX Slow method of traversal. This is necessary if every item must
* be touched. If OBJ_POINTER is one of the search flags, then we can attempt a quicker
* version of traversal using the same algorithm used in skiplist_link.
@@ -194,6 +198,8 @@
void *ret = NULL;
int i;
+ ast_assert(skip_pvt);
+
if (a->c->version == a->c_version && (item = a->obj)) {
if ((item = AST_LIST_NEXT(item, entry[0]))) {
goto found;
@@ -214,6 +220,8 @@
struct skiplist_pvt *skip_pvt = c->private;
struct list_item *iter;
+ ast_assert(skip_pvt);
+
while ((iter = AST_LIST_REMOVE_HEAD(skip_pvt->skiplist, entry[0]))) {
ast_free(iter);
}
More information about the asterisk-commits
mailing list