summaryrefslogtreecommitdiff
path: root/main/format.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2014-06-11 23:01:19 +0000
committerRichard Mudgett <rmudgett@digium.com>2014-06-11 23:01:19 +0000
commit71b3c9a749b9eb910ea6e5353d3703f93709cb29 (patch)
treef485880081ccec31d439ba622aaf99d65148d971 /main/format.c
parentd5298f2a1bef3c648f43387970ad1a6694aa4390 (diff)
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. ........ Merged revisions 415728 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 415729 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415730 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/format.c')
-rw-r--r--main/format.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/main/format.c b/main/format.c
index a41f26b4c..d24e1c386 100644
--- a/main/format.c
+++ b/main/format.c
@@ -984,10 +984,6 @@ static int list_cmp_cb(void *obj, void *arg, int flags)
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)
{
@@ -1040,7 +1036,7 @@ static int build_format_list_array(void)
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! */