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
This commit is contained in:
Corey Farrell
2017-12-29 23:59:00 -05:00
parent 80e6b2eff5
commit bc73337e07
10 changed files with 54 additions and 668 deletions

View File

@@ -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;
}