[asterisk-commits] mmichelson: branch mmichelson/ao2_containers r140549 - /team/mmichelson/ao2_c...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Aug 30 21:01:36 CDT 2008


Author: mmichelson
Date: Sat Aug 30 21:01:36 2008
New Revision: 140549

URL: http://svn.digium.com/view/asterisk?view=rev&rev=140549
Log:
First draft of astobj2_skiplist.c

There are probably some kinks to work out, including
what I've placed in XXX comments. Specifically, what
needs to be done is to make skiplist_callback execute
a quick traversal to search for an item if OBJ_POINTER
is one of the search flags passed in.

Also in this commit, I have fixed some memory leaks
which would occur due to allocation failures and 
I fixed a rather grievous error in the linkedlist_link
functions.


Added:
    team/mmichelson/ao2_containers/main/astobj2_skiplist.c   (with props)
Modified:
    team/mmichelson/ao2_containers/main/astobj2_hashtable.c
    team/mmichelson/ao2_containers/main/astobj2_linkedlist.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=140549&r1=140548&r2=140549
==============================================================================
--- team/mmichelson/ao2_containers/main/astobj2_hashtable.c (original)
+++ team/mmichelson/ao2_containers/main/astobj2_hashtable.c Sat Aug 30 21:01:36 2008
@@ -78,7 +78,7 @@
 	}
 
 	if (!(hash_pvt = ast_calloc(1, sizeof (*hash_pvt) + (n_buckets * sizeof(struct bucket))))) {
-		/* OH CRAP */
+		ao2_ref(c, -1);
 		return NULL;
 	}
 

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=140549&r1=140548&r2=140549
==============================================================================
--- team/mmichelson/ao2_containers/main/astobj2_linkedlist.c (original)
+++ team/mmichelson/ao2_containers/main/astobj2_linkedlist.c Sat Aug 30 21:01:36 2008
@@ -57,6 +57,7 @@
 	}
 
 	if (!(new_list = ast_calloc(1, sizeof(*new_list)))) {
+		ao2_ref(list, -1);
 		return NULL;
 	}
 
@@ -74,6 +75,7 @@
 	}
 
 	if (!(new_list = ast_calloc(1, sizeof(*new_list)))) {
+		ao2_ref(list, -1);
 		return NULL;
 	}
 
@@ -90,6 +92,9 @@
 		return NULL;
 	}
 
+	item->astobj = newobj;
+	item->version = ast_atomic_fetchadd_int(&c->version, 1);
+
 	AST_LIST_INSERT_TAIL(list, item, entry);
 	return item;
 }
@@ -102,6 +107,9 @@
 	if (!item) {
 		return NULL;
 	}
+	
+	item->astobj = newobj;
+	item->version = ast_atomic_fetchadd_int(&c->version, 1);
 
 	AST_LIST_INSERT_HEAD(list, item, entry);
 	return item;
@@ -134,7 +142,7 @@
 			AST_LIST_REMOVE_CURRENT(entry);
 			ast_atomic_fetchadd_int(&c->elements, -1);
 			ao2_ref(EXTERNAL_OBJ(x->astobj), -1);
-			free(x);
+			ast_free(x);
 		}
 
 		if ((match & CMP_STOP) || (flags & OBJ_MULTIPLE) == 0) {

Added: team/mmichelson/ao2_containers/main/astobj2_skiplist.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/ao2_containers/main/astobj2_skiplist.c?view=auto&rev=140549
==============================================================================
Binary file - no diff available.

Propchange: team/mmichelson/ao2_containers/main/astobj2_skiplist.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mmichelson/ao2_containers/main/astobj2_skiplist.c
------------------------------------------------------------------------------
    svn:mime-type = plain/text




More information about the asterisk-commits mailing list