[asterisk-commits] rmudgett: branch 11 r415728 - /branches/11/main/format.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 11 17:44:38 CDT 2014


Author: rmudgett
Date: Wed Jun 11 17:44:30 2014
New Revision: 415728

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=415728
Log:
format.c: Fix misuse of hash container function.

The supplied hash function to a container must be idempotent given the
object's key value to figure out which container bucket the object belongs
in.  Returning a random number or the current container count is not
idempotent.  The "computed hash" value doesn't help find the object later
in those cases.

* Fixed the format_list container to actually be a list since that is how
the container is used.  Conceptually, if more than 283 formats were added
to the format_list then odd things may have happened before the fix.

Modified:
    branches/11/main/format.c

Modified: branches/11/main/format.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/format.c?view=diff&rev=415728&r1=415727&r2=415728
==============================================================================
--- branches/11/main/format.c (original)
+++ branches/11/main/format.c Wed Jun 11 17:44:30 2014
@@ -973,10 +973,6 @@
 
 	return (ast_format_cmp(&entry1->format, &entry2->format) == AST_FORMAT_CMP_EQUAL) ? CMP_MATCH | CMP_STOP : 0;
 }
-static int list_hash_cb(const void *obj, const int flags)
-{
-	return ao2_container_count(format_list);
-}
 
 const struct ast_format_list *ast_format_list_get(size_t *size)
 {
@@ -1029,7 +1025,7 @@
 static int format_list_init(void)
 {
 	struct ast_format tmpfmt;
-	if (!(format_list = ao2_container_alloc(283, list_hash_cb, list_cmp_cb))) {
+	if (!(format_list = ao2_container_alloc(1, NULL, list_cmp_cb))) {
 		return -1;
 	}
 	/* initiate static entries XXX DO NOT CHANGE THIS ORDER! */




More information about the asterisk-commits mailing list