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>2017-12-30 13:20:16 -0500
commitbc73337e0796d7b85b7b4f86d427b4212b895745 (patch)
tree017a012d065fed8a132c6c747215aa446e5e0d38 /main/codec.c
parent80e6b2eff54a4ff57e2521164224b1b1c878ae94 (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) * ast_bucket_file (media_cache.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 5b262f6a1..d6de072e7 100644
--- a/main/codec.c
+++ b/main/codec.c
@@ -73,24 +73,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)
{
@@ -265,7 +248,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;
}