summaryrefslogtreecommitdiff
path: root/main/codec.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2017-12-29 23:59:00 -0500
committerCorey Farrell <git@cfware.com>2018-01-01 19:17:15 -0500
commit5b395a7b97775f62083675f13537179150befd3f (patch)
tree466e3550e77dd543e0eb52a20d8499c6a443e081 /main/codec.c
parentb47882df72fbeae6ab340b21817d7f3fc4a1ba97 (diff)
core: Use macros to generate ao2_container callbacks where possible.
This uses AO2_STRING_FIELD_HASH_FN and AO2_STRING_FIELD_CMP_FN where possible in the Asterisk core. This removes CMP_STOP from the result of CMP_FN callbacks for the following structure types: * ast_bucket_metadata * ast_bucket_scheme * generic_monitor_instance_list (ccss.c) * named_acl Change-Id: Ide4c1449a894bce70dea1fef664dade9b57578f1
Diffstat (limited to 'main/codec.c')
-rw-r--r--main/codec.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/main/codec.c b/main/codec.c
index d0e63682b..05cee4ab6 100644
--- a/main/codec.c
+++ b/main/codec.c
@@ -75,24 +75,7 @@ struct internal_ast_codec {
int __ast_codec_register_with_format(struct ast_codec *codec, const char *format_name,
struct ast_module *mod);
-static int codec_hash(const void *obj, int flags)
-{
- const struct ast_codec *codec;
- const char *key;
-
- switch (flags & OBJ_SEARCH_MASK) {
- case OBJ_SEARCH_KEY:
- key = obj;
- return ast_str_hash(key);
- case OBJ_SEARCH_OBJECT:
- codec = obj;
- return ast_str_hash(codec->name);
- default:
- /* Hash can only work on something with a full key. */
- ast_assert(0);
- return 0;
- }
-}
+AO2_STRING_FIELD_HASH_FN(ast_codec, name)
static int codec_cmp(void *obj, void *arg, int flags)
{
@@ -267,7 +250,8 @@ static void codec_shutdown(void)
int ast_codec_init(void)
{
- codecs = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, CODEC_BUCKETS, codec_hash, codec_cmp);
+ codecs = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, CODEC_BUCKETS,
+ ast_codec_hash_fn, codec_cmp);
if (!codecs) {
return -1;
}